So I gotta deal with some xml that looks like this:
<ns2:foobarResponse xmlns:ns2="http://api.example.com">
<duration>206</duration>
<artist>
<tracks>...</tracks>
</artist>
</ns2:foobarResponse>
I found lxml and it's objectify module, that lets you traverse a xml document in a pythonic way, like a dictionary.
Problem is: it's using the bogus xml namespace every time you try to access an element, like this:
from lxml import objectify
tree = objectify.fromstring(xml)
print tree.artist
# ERROR: no such child: {http://api.example.com}artist
It's trying to access <artist>
with the parent namespace, but the tag doesn't use the ns.
Any ideas how to get around this? Thanks