You should take a look at the xml you get. Probably the problem is that you get not only the tags in the root directory of the node, but also the text.
For instance:
>>> xml_doc = minidom.parseString('<root>text<tag></tag></root>')
>>> root = xml.documentElement
>>> root.childNodes
[<DOM Text node "u'root node '...">, <DOM Element: tag at 0x2259368>]
Note that in my example, the first node is the text node, and the second is the tag. Thus, it root.childNodes[0].tagNameraises the same exception that you get, and root.childNodes[1].tagNamereturns only tagas expected.
source
share