I'm trying to parse an XML document with a default namespace, i.e. the root node has an xmlns
attribute. This is annoying if you want to try find certain tags in the child nodes because each tag is prefixed with the default namespace.
xml.etree.ElementTree.findall()
allows for a namespaces
dictionary to be passed in but I can't seem to find what the default namespace is mapped to. I have tried using 'default', None, 'xmlns' with no success.
One option that does seem to work is to prefix the tag passed to findall()
with 'xmlns:' (EDIT: this can be any arbitrary unique name actually) and a corresponding entry in the namespaces dictionary but I'm wondering if that is even necessary.
EDIT: I should mention this is Python 3.3.2. I believe in older versions of Python, findall()
does not accept a namespaces
argument.