Microsoft XML SDK 2.6 - XML Reference

selectNodes Method (XMLDOMDocument2)

Changes select nodes to return an XMLDOMSelection object. The returned object inherits the threading model of the document object.

Set objXMLDOMSelection = objXMLDOMDocument2.selectNodes(strExpr)

Parameters

strExpr
The XQL or XPath instruction. (For details, see XMLDOMSelection).

Example

Dim xmldoc As New MSXML2.DOMDocument
Dim selection As MSXML2.IXMLDOMSelection

xmldoc.loadXML ("<Customer><Name>Microsoft</Name></Customer>")
xmldoc.setProperty "SelectionLanguage", "XPath"
Set selection = xmldoc.selectNodes("Customer/Name")
MsgBox selection.expr + " -- " + selection.Item(0).xml

The above message box displays "Customer/Name -- <Name>Microsoft</Name>"

selection.expr = "/Customer"
MsgBox selection.expr + " -- " + selection.Item(0).xml

The above message box displays "/Customer –-<Customer><Name>Microsoft</Name></Customer>"

See Also

Applies To: XMLDOMDocument2 Object