CustomXMLPart.SelectNodes 方法 (Office)

从自定义 XML 部件中选择节点的集合。

语法

表达式SelectNodes (XPath)

表达 返回 CustomXMLPart 对象的表达式。

参数

名称 必需/可选 数据类型 说明
XPath 必需 字符串 包含 XPath 表达式。

返回值

CustomXMLNodes

示例

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

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]") 

另请参阅

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。