Edit

CustomXMLNode.SelectNodes method (Office)

Selects a collection of nodes matching an XPath expression. This method differs from the CustomXMLPart.SelectNodes method in that the XPath expression will be evaluated starting with the 'expression' node as the context node.

Syntax

expression.SelectNodes(XPath)

expression An expression that returns a CustomXMLNode object.

Parameters

Name Required/Optional Data type Description
XPath Required String Contains an XPath expression.

Return value

CustomXMLNodes

Example

The following example demonstrates adding a custom XML part, selecting a part matching a namespace URI, and then selecting nodes within that part that match an XPath expression.

Dim cxp1 As CustomXMLPart 
Dim cxn As CustomXMLNode 
 
' Add a custom xml part. 
ActiveDocument.CustomXMLParts.Add "<supplier>" 
 
' Return the first custom xml part with the given namespace. 
Set cxp1 = ActiveDocument.CustomXMLParts("urn:invoice:namespace")  
 
' Get all of the nodes matching an XPath expression. 
 Set cxns = cxp1.SelectNodes("//*[@unitPrice > 20]")

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.