reset Method (IXMLDOMNodeList)

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - DOM Reference

reset Method (IXMLDOMNodeList)

Resets the iterator.

[Script]

Script Syntax

oXMLDOMNodeList.reset();

Example

The following script example creates an IXMLDOMNodeList object and iterates the collection using the nextNode method. It then uses the reset method to reset the iterator to point before the first node in the list.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");
var objNodeList;
var objNode;
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode <> 0) {
   var myErr = xmlDoc.parseError;
   alert("You have error " + myErr.reason);
} else {
   objNodeList = xmlDoc.getElementsByTagName("author");
   for (var i=0; i<objNodeList.length; i++) {
      objNode = objNodeList.nextNode();
      alert(objNode.text);
   }
   objNodeList.reset();
   objNode = objNodeList.nextNode();
   alert(objNode.text);
}
[Visual Basic]

Visual Basic Syntax

oXMLDOMNodeList.reset

Example

The following Microsoft® Visual Basic® example creates an IXMLDOMNodeList object and iterates the collection using the nextNode method. It then uses the reset method to reset the iterator to point before the first node in the list.

Dim xmlDoc As New Msxml2.DOMDocument50
Dim objNodeList As IXMLDOMNodeList
Dim objNode As IXMLDOMNode
xmlDoc.async = False
xmlDoc.Load ("books.xml")
If (xmlDoc.parseError.errorCode <> 0) Then
   Dim myErr
   Set myErr = xmlDoc.parseError
   MsgBox("You have error " & myErr.reason)
Else
   Set objNodeList = xmlDoc.getElementsByTagName("author")
   For i = 0 To (objNodeList.length - 1)
      Set objNode = objNodeList.nextNode
      MsgBox objNode.Text
   Next
   objNodeList.Reset
   Set objNode = objNodeList.nextNode
   MsgBox objNode.Text
End If
[C/C++]

C/C++ Syntax

HRESULT reset(void);

C/C++ Return Values

S_OK
The value returned if successful.

Remarks

This method reinitializes the iterator to point before the first node in the IXMLDOMNodeList so that the next call to nextNode returns the first item in the list.

This member is an extension of the Worldwide Web Consortium (W3C) Document Object Model (DOM).

To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button Language Filter in the upper-left corner of the page.

See Also

nextNode Method

Applies to: IXMLDOMNodeList | IXMLDOMSelection