2010-09-16 12 views
5

Sto cercando di analizzare un file xml con python-amara.Stampa dei valori degli attributi in python-amara

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

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

print m 

Quando faccio questo dà

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

Tuttavia quando provo questo:

print doc.HOP.A.D 

dice:

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

Qualche idea?

risposta

1

per accedere agli elementi in un modo che si sta tentando di farlo, è necessario utilizzare

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

invece di

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