xml minidom redundant children??

MonkeeSage MonkeeSage at gmail.com
Thu Mar 1 20:27:50 CET 2007


On Mar 1, 12:46 pm, bkamr... at gmail.com wrote:
> As a newbie, I'm trying to simply parse a xml file using minidom, but
> I don't know why I get some extra children(?). I don't know what is
> wrong in xml file, but I've tried different xml files, still same
> problem.

Most simply, if you need to stick with xml.dom.minidom; just check the
nodeType and make sure its not 3 (textNode):

from xml.dom import minidom
doc = minidom.parse(fileTest)
for item in doc.documentElement.childNodes:
    if not item.nodeType == 3:
        print item.nodeName

Regards,
Jordan




More information about the Python-list mailing list