matches Method

 

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

JScript Syntax

objXMLDOMNode = objXMLDOMSelection.matches(objXMLDOMNode);  

Example

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
var oSelection, nodeBook, node;
xmlDoc.setProperty("SelectionLanguage", "XPath");
xmlDoc.async = false;
xmlDoc.loadXML("<root><child/></root>");
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   nodeBook = xmlDoc.selectSingleNode("//child");
   oSelection = xmlDoc.selectNodes("//*");
   node = oSelection.matches(nodeBook);
   WScript.Echo(node.xml);
}

Output

Outputs the books.xml file.

C/C++ Syntax

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

Parameters

pNode[in]
The node that is passed in.

ppNode[out, retval]
The Boolean result.

Return Values

S_OK
The value returned if method successful.

E_INVALIDARG
The value returned if the pNodeparameter isNull.

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.

Versioning

Implemented in: MSXML 3.0 and MSXML 6.0

See Also

IXMLDOMSelection