Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Printing Attribute Values in python-amara

I'm trying to parse an xml file with using python-amara.

doc = amara.parse('h.xml')

assert doc.xml_type == tree.entity.xml_type
m = doc.xml_children[0]

print m

When I do this it gives

amara.tree.element at 0x94c864c: name u'HOP', 0 namespaces, 0 attributes, 93 children

However when I try this :

print doc.HOP.A.D

it says:

AttributeError: 'amara.tree.entity' object has no attribute 'HOP'

Any idea?

like image 742
iva123 Avatar asked Nov 15 '22 07:11

iva123


1 Answers

To access elements in a way you are trying to do it, you must use

from amara import bindery
doc = bindery.parse('h.xml')

instead of

doc = amara.parse('h.xml')
like image 91
utapyngo Avatar answered Nov 17 '22 06:11

utapyngo