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 开发者_如何学C== 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?
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')
精彩评论