SelectNodes 方法 (Office) CustomXMLPartCustomXMLPart.SelectNodes method (Office)

从自定义 XML 部件中选择节点的集合。Selects a collection of nodes from a custom XML part.



_表达式_一个返回**CustomXMLPart** 对象的表达式。expression An expression that returns a CustomXMLPart object.


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
XPathXPath 必需Required StringString 包含 XPath 表达式。Contains the XPath expression.

返回值Return value



以下示例说明了添加自定义 XML 部件,选择与命名空间 URI 匹配的部件,然后在该部件内选择与 XPath 表达式匹配的节点。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

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.