Re: xml.dom.minidom - documentElement vs. childNodes

> > 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.

Comments, processing instructions and whitespace text nodes can come
before the document element, and in that way becoem the children of
the document node.  Minidom doesn't keep document-level whitespace,
but som DOM impls do.

Furthermore the doctype of the document is a child of the document
node.

--- GoldED/386 2.42.G0614+
 * Origin: Everything goes the bach runter ... 
 * http://online6casino.com

Received on Wednesday, 8 September 2004 07:07:31 UTC