peekNode Method


Gets the next node that the nextNode method will return without advancing the list position.

var objXMLDOMNode = objXMLDOMSelection.peekNode();  


System_CAPS_ICON_note.jpg Note

You can use books.xml to run this sample code.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
var oSelection, nodeBook;
xmlDoc.setProperty("SelectionLanguage", "XPath");
xmlDoc.async = false;
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   oSelection = xmlDoc.selectNodes("//book");
   nodeBook = oSelection.peekNode();


<book id="bk101">  
   <author>Gambardella, Matthew</author>  
   <title>XML Developer's Guide</title>  
   <description>An in-depth look at creating applications   
   with XML.</description>  

HRESULT peekNode (IXMLDOMNode** ppNode);  


ppNode[out, retval]
The returned node, or Null if there are no more nodes or if E_PENDING is returned.

Return Values

The value returned if the method is successful.

The value returned if the context document is still being built and the selection object has hit the end of the available nodes to match.

Like nextNode, peekNode does not result in a snapshot of all matching nodes. In MSXML 6.0, consecutive calls to peekNode will produce the same node over and over, independent of changes in the underlying tree. MSXML 3.0 does not not return the same node if the underlying data is modified.

Implemented in: MSXML 30 and MSXML 6.0