XMLNode.SelectNodes(String, String, Boolean) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public Microsoft.Office.Interop.Word.XMLNodes SelectNodes (string XPath, string PrefixMapping = "", bool FastSearchSkippingTextNodes = true);
abstract member SelectNodes : string * string * bool -> Microsoft.Office.Interop.Word.XMLNodes
Public Function SelectNodes (XPath As String, Optional PrefixMapping As String = "", Optional FastSearchSkippingTextNodes As Boolean = true) As XMLNodes
Parameters
- XPath
- String
A valid XPath string.
- PrefixMapping
- String
Provides the prefix in the schema against which to perform the search. Use the PrefixMapping
parameter if your XPath
parameter uses names to search for elements.
- FastSearchSkippingTextNodes
- Boolean
true
to skip all text nodes while searching for the specified node. false
to include text nodes in the search. Default value is false
.
Returns
The nodes that match the XPath
parameter in the order in which they appear in the XMLNode control.
Examples
The following code example uses the SelectNodes method to get a collection of the child nodes that match the given XPath
parameter. The example then displays the number of nodes that were found. This example assumes that the current document contains an XMLNode named CustomerNode
with a matching schema element that contains one or more child nodes named FirstName
.
private void DisplayFirstNameNodesCount()
{
string element = "/x:Customer/x:FirstName";
string prefix = "xmlns:x='" +
this.CustomerFirstNameNode.NamespaceURI + "'";
Word.XMLNodes nodes = this.CustomerNode.SelectNodes(element,
prefix, true);
MessageBox.Show(nodes.Count + " element(s) were found.");
}
Private Sub DisplayFirstNameNodesCount()
Dim element As String = "/x:Customer/x:FirstName"
Dim prefix As String = "xmlns:x='" & _
Me.CustomerFirstNameNode.NamespaceURI & "'"
Dim nodes As Word.XMLNodes = _
Me.CustomerNode.SelectNodes(element, prefix, True)
MsgBox(nodes.Count & " element(s) were found.")
End Sub
Remarks
Setting the FastSearchSkippingTextNodes
parameter to false
diminishes performance, because Microsoft Office Word searches all nodes in a document for the text contained in the node.
Optional Parameters
For information on optional parameters, see Optional Parameters in Office Solutions.