次の方法で共有


peekNode Method

 

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

JScript Syntax

var objXMLDOMNode = objXMLDOMSelection.peekNode();  

Example

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;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   oSelection = xmlDoc.selectNodes("//book");
   nodeBook = oSelection.peekNode();
   WScript.Echo(nodeBook.xml);
}

Output

<book id="bk101">  
   <author>Gambardella, Matthew</author>  
   <title>XML Developer's Guide</title>  
   <genre>Computer</genre>  
   <price>44.95</price>  
   <publish_date>2000-10-01</publish_date>  
   <description>An in-depth look at creating applications   
   with XML.</description>  
</book>  

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.

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. 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.

Versioning

Implemented in: MSXML 30 and MSXML 6.0

See Also

IXMLDOMSelection