METHOD:  NodeList::nextNode

This method is a Microsoft extension to the W3C DOM.

NodeList.nextNode( )

The nextNode method returns the next node in the collection. The iterator is initially positioned before the first item in the list, so the first call to nextNode returns the first node.

If there are no items in the collection, or the current node is the last, the nextNode method will return null. If the current node is removed, subsequent calls to nextNode will also return null unless the iterator is reset using the reset method.

In the following example we load the 'beers.xml' file and create a collection of all 'brewer' element nodes. The code then iterates through the collection using the nextNode method, and displays the text of each.

XML:
<beers>
   <beer>
      <brewer>Badger</brewer>
      <name>Tanglefoot</name>
   </beer>
   <beer>
      <brewer>Wadworths</brewer>
      <name>6X</name>
   </beer>
   <beer>
      <brewer>Hop Back Brewery</brewer>
      <name>Summer Lightning</name>
   </beer>
</beers>

Code (VBScript):
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("beers.xml")

Set NodeList = objXMLDoc.getElementsByTagName("brewer")
numNodes = NodeList.Length
For i = 1 To NumNodes
   Set CurrNode = NodeList.nextNode
   document.write(CurrNode.text & "<br>")
Next

Output:
Badger
Wadworths
Hop Back Brewery



Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information