O'Reilly logo

Real World XML by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The XMLDOMNodeList Object

You use the XMLDOMNodeList to handle lists of nodes, and node lists are useful because a node can itself have many child nodes. Using a node list, you can handle all the children of a node at once.

For example, here I'm loading a document and getting a list of all <PERSON> elements as a node list, using the document object's getElementsByTagName method:

function readXMLDocument() 
{
    var xmldoc, nodeList
    xmldoc = new ActiveXObject("Microsoft.XMLDOM")
    xmldoc.load("ch07_01.xml")
    nodeList = xmlDoc.getElementsByTagName("PERSON")
    .
    .
    .

Here is the base set of properties for the XMLDOMNodeList object:

  • length— Number of items in the collection. Read-only.

Here is the base set of methods for the XMLDOMNodeList object:

  • item

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required