开发者

Printing Attribute Values in python-amara

开发者 https://www.devze.com 2023-01-16 16:09 出处:网络
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

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')
0

精彩评论

暂无评论...
验证码 换一张
取 消