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

peekNode Method

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

[Script]

Script Syntax

var objXMLDOMNode = objXMLDOMSelection.peekNode();

Example

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");
var oSelection, nodeBook;
xmlDoc.setProperty("SelectionLanguage", "XPath");
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode <> 0) {
   var myErr = xmlDoc.parseError;
   alert("You have error " + myErr.reason);
} else {
   oSelection = xmlDoc.selectNodes("//book");
   nodeBook = oSelection.peekNode();
   alert(nodeBook.xml);
}
[Visual Basic]

Visual Basic Syntax

Set objXMLDOMNode = objXMLDOMSelection.peekNode

Example

Dim xmlDoc As New Msxml2.DOMDocument50
Dim oSelection As IXMLDOMSelection
Dim nodeBook As IXMLDOMElement
xmlDoc.setProperty "SelectionLanguage", "XPath"
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 oSelection = xmlDoc.selectNodes("//book")
   Set nodeBook = oSelection.peekNode()
   MsgBox nodeBook.xml
End If
[C/C++]

C/C++ Syntax

HRESULT peekNode (IXMLDOMNode** ppNode);

Parameters

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

C/C++ Return Values

S_OK
The value returned if the method is successful.
E_PENDING
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.

Remarks

Like nextNode, peekNode does not result in a snapshot of all matching nodes. Consecutive calls to peekNode will produce the same node over and over, independent of changes in the underlying tree.

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

Applies to: IXMLDOMSelection