matches Method

MSXML 5.0 SDK

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

matches Method

Checks if the node that is passed is contained in the current collection.

[Script]

Script Syntax

objXMLDOMNode = objXMLDOMSelection.matches(objXMLDOMNode);

Example

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");
var oSelection, nodeBook, node;
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 {
   nodeBook = xmlDoc.selectSingleNode("//book");
   oSelection = xmlDoc.selectNodes("//*");
   node = oSelection.matches(nodeBook);
   alert(node.xml);
}
[Visual Basic]

Visual Basic Syntax

objXMLDOMNode = objXMLDOMSelection.matches(objXMLDOMNode)

Example

Dim xmlDoc As New Msxml2.DOMDocument50
Dim oSelection As IXMLDOMSelection
Dim nodeBook As IXMLDOMNode
Dim node As IXMLDOMNode
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 nodeBook = xmlDoc.selectSingleNode("//book")
   Set oSelection = xmlDoc.selectNodes("//*")
   Set node = oSelection.matches(nodeBook)
   MsgBox node.xml
End If
[C/C++]

C/C++ Syntax

HRESULT matches(IXMLDOMNode* pNode, IXMLDOMNode** ppNode);

Parameters

pNode [in]
The node that is passed in.
ppNode [out, retval]
The Boolean result.

C/C++ Return Values

S_OK
The value returned if method successful.
E_INVALIDARG
The value returned if the pNode parameter is Null.

An error for cases that are not allowed, as outlined in the Extensible Stylesheet Language (XSL) specification (applied to ID, IDREF, and Ancestor).

Remarks

When matches is called with node A, it returns node B such that if B was set as the context on a query, A is in the result set of the query. If no such B node is found, matches returns Null.

The matches method does not take into account the current context of the query.

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