Free since 2005 · No login required
AT

Academic Tutorials

Learn at your own pace

site-mobile-top-banner · 320x50

Accessing the DOM

Added 26 Jul 2008

Traversing the node tree

One very common way to extract XML elements from an XML document is to traverse the node three and extract the text value of each elements. A small snippet of programming code like a VBScript for/each construct can be written to demonstrate this.

The following VBScript code traverses an XML node tree, and displays the XML elements in the browser:

set xmlDoc=CreateObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.load("note.xml")

for each x in xmlDoc.documentElement.childNodes
document.write(x.nodename)
document.write(": ")
document.write(x.text)
next