xml.dom.minidom - documentElement vs. childNodes
Peter Otten
__peter__ at web.de
Mon Aug 30 16:45:49 EDT 2004
Skip Montanaro wrote:
> I'm getting somewhat painfully acquainted with xml.dom.minidom. What is
> the relationship between its documentElement attribute and its childNodes
> list?
> I thought XML documents consisted of a single, possibly compound, node.
> Why is a list of childNodes needed?
>>> import xml.dom.minidom as md
>>> dom = md.parseString("""<?xml version="1.0" ?><!--comment--><root/>""")
>>> dom.childNodes
[<DOM Comment node "comment">, <DOM Element: root at 0x4038c1ac>]
>>>
Seems like comments are preserved in childNodes, too.
Peter
More information about the Python-list
mailing list