I want to execute iterfind() for elements with a namespace, but without a prefix. I would call
iterfind([tagname]) or iterfind([tagname], [namespace dict])
I do not need to enter the tag as follows:
"{%s}tagname" % tree.nsmap[None]
More details
I am using the XML response from the Google API. The root node defines several namespaces, including one for which there is no prefix: xmlns="http://www.w3.org/2005/Atom"
It seems that when I try to search on my etrera, everything behaves as I would expect from prefixed items. eg:.
>>> for x in root.iterfind('dxp:segment'): print x ... <Element {http://schemas.google.com/analytics/2009}segment at 0x1211b98> <Element {http://schemas.google.com/analytics/2009}segment at 0x1211d78> <Element {http://schemas.google.com/analytics/2009}segment at 0x1211a08> >>>
But when I try to search for something without a prefix, the search does not automatically add a namespace for root.nsmap[None] . eg:.
>>> for x in root.iterfind('entry'): print x ... >>>
Even if I try to throw away the namespace map as an optional argument to iterfind , it will not attach the namespace.
source share