reset Method (IXMLDOMNodeList)
Resets the iterator.
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.
You can use books.xml to run this sample code. |
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0"); var objNodeList; var objNode; xmlDoc.async = false; xmlDoc.load("books.xml"); if (xmlDoc.parseError.errorCode != 0) { var myErr = xmlDoc.parseError; WScript.Echo("You have error " + myErr.reason); } else { objNodeList = xmlDoc.getElementsByTagName("author"); for (var i=0; i<objNodeList.length; i++) { objNode = objNodeList.nextNode(); WScript.Echo(objNode.text); } objNodeList.reset(); objNode = objNodeList.nextNode(); WScript.Echo(objNode.text); }
Output
Gambardella, Matthew Ralls, Kim Corets, Eva ...
HRESULT reset(void);
Return Values
S_OK
The value returned if successful.
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).
Implemented in: MSXML 3.0 and MSXML 6.0
nextNode Method (IXMLDOMNodeList)
IXMLDOMNodeList
IXMLDOMSelection
Show: