So, I have to 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 the lxml and objectify module, which allows you to move the XML document as a pythonic, for example, in a dictionary. <sh> The problem is that it uses a fake xml namespace every time you try to access an element, for example:
from lxml import objectify
tree = objectify.fromstring(xml)
print tree.artist
It tries to access <artist>with the parent namespace, but the tag does not use ns.
Any ideas how to get around this? Thanks
source
share