XMLMapping.XPath 属性

定义

返回一个 字符串 ,表示为 XML 映射,其计算结果为当前映射的 XML 节点的 XPath。 此为只读属性。

public:
 property System::String ^ XPath { System::String ^ get(); };
public string XPath { get; }
member this.XPath : string
Public ReadOnly Property XPath As String

属性值

示例

以下示例检查活动文档中第一个内容控件是否是日期控件,以及 XPath 字符串是否设置为特定的内置文档属性。 如果 XPath 不匹配并且控件是日期控件,它将设置到该控件的映射。

<span class="label">Dim objCC As ContentControl































































































































Dim objMap As XMLMapping































































































































Dim blnMap As Boolean































































































































































































































































Set objCC = ActiveDocument.ContentControls(1)































































































































Set objMap = objCC.XMLMapping































































































































































































































































If (objCC.Type = wdContentControlDate) And (objMap.</span>
<span class="label">XPath</span>
<span class="label">&lt;&gt; _        "/ns1:coreProperties[1]/ns0:createdate[1]") Then    blnMap = objMap.SetMapping(XPath:="/ns1:coreProperties[1]/ns0:createdate[1]")    If blnMap = False Then        MsgBox "Unable to map the content control."    End IfEnd If</span>

注解

若要设置内容控件的映射,请使用 SetMapping(String, String, CustomXMLPart) 方法或 SetMappingByNode(CustomXMLNode) 方法。 如果映射不是活动的,则使用此属性将返回错误。

适用于