I’ve got some simple code stepping through a large XML file (containing entities defined in the DTD):
from lxml import etree
tree = etree.parse(
file('t.xml', 'r'), etree.XMLParser(dtd_validation=False, load_dtd=True))
for e in tree.iter('bla'):
process(e) # whatever to be done with it
This works nicely for plain XML input.
Unfortunately the iter generator does not yield anything for tags with colons inside (namespace prefix). The namespace is not defined anywhere, and actually I don’t care about it. I just want to iterate through the elements.
Is there an easy way to do this?
Well, this may not be entirely satisfying, but here is what I found:
for a tag like:
But this should allow you to get everything:
attribnsmap