By default, when you call ElementTree.parse(someXMLfile) the Python ElementTree library prefixes every parsed node with it's namespace URI in Clark's Notation:
{http://example.org/namespace/spec}mynode
This makes accessing specific nodes by name a huge pain later in the code.
I've read through the docs on ElementTree and namespaces and it looks like the iterparse()
function should allow me to alter the way the parser prefixes namespaces, but for the life of me I can't actually make it change the prefix. It seems like that may happen in the background before the ns-start event even fires as in this example:
for event, elem in iterparse(source):
if event == "start-ns":
namespaces.append(elem)
elif event == "end-ns":
namespaces.pop()
else:
...
How do I make it change the prefixing behavior and what is the proper thing to return when the function ends?