Document.documentElement
The documentElement property exists for convenient access to
the root element of the document. It returns an Element object,
or null if no root element exists.
The example that follows first loads the 'library.xml' file, and then
creates an Element object from the documentElement property
and iterates through its child nodes, printing the text of each.
XML:
<library>
<book>
<category>fiction</category>
<title>Eyeless
in Gaza</title>
<author>Aldous
Huxley</author>
</book>
<book>
<category>classics</category>
<title>John
Barleycorn</title>
<author>Jack
London</author>
</book>
</library>
Code (VBScript):
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("library.xml")
Dim root, i
Set root = objXMLDoc.documentElement
For i = 0 To (root.childNodes.length)
document.write(root.childNodes.item(i).text & "<br>")
Next
Output:
fiction Eyeless in Gaza Aldous Huxley
classics John Barleycorn Jack London
|