カスタム XML 部分から XPath 式に一致するシングル ノードを選択します。
構文
式。SelectSingleNode(XPath)
式CustomXMLPart オブジェクトを返す式。
パラメーター
名前 | 必須 / オプション | データ型 | 説明 |
---|---|---|---|
XPath | 必須 | String | XPath 式を指定します。 |
戻り値
CustomXMLNode
例
次の例では、カスタム XML 部分を追加し、名前空間 URI に一致する部分を選択し、その部分から XPath 式に一致するノードを 1 つ選択します。
Dim cxp1 As CustomXMLPart
Dim cxn As CustomXMLNode
' Add a custom XML part.
ActiveDocument.CustomXMLParts.Add ( _
"<suppliers>" & _
"<supplier ID='1'>Contoso</supplier>" & _
"<supplier ID='2'>Wingtip Toys</supplier>" & _
"</suppliers>")
' Return the last custom XML part added to the document.
Set cxp1 = ActiveDocument.CustomXMLParts(ActiveDocument.CustomXMLParts.Count)
' Get a node using XPath.
Set cxn = cxp1.SelectSingleNode("//supplier[@ID=1]")
' Display the node value 'Contoso'.
MsgBox cxn.NodeValue
関連項目
サポートとフィードバック
Office VBA またはこの説明書に関するご質問やフィードバックがありますか? サポートの受け方およびフィードバックをお寄せいただく方法のガイダンスについては、Office VBA のサポートおよびフィードバックを参照してください。