My XML looks like:
...
<termEntry id="c1">
<langSet xml:lang="de">
...
And i have the code:
from lxml import etree
...
for term_entry in root.iterfind('.//termEntry'):
print term_entry.attrib['id']
print term_entry.nsmap
for lang_set in term_entry.iterfind('langSet'):
print lang_set.nsmap
print lang_set.attrib
for some_stuff in lang_set.iterfind('some_stuff'):
...
I get the empty nsmap dict, and my attrib dict looks like {'{http://www.w3.org/XML/1998/namespace}lang': 'en'}
The file may not contain xml:
in namespace, or it may have a different namespace. How can i know what namespace used in the tag declaration? In fact, i just need to get a lang
attribute, i don't care what namespace was used. I don't want use any crappy trash like lang_set.attrib.values()[0]
or other lookups of a field with the known name.