System.Xml.XPath.XPathNavigator.Select Method

Selects a node set, using the specified XPath expression.

Syntax

public virtual XPathNodeIterator Select (string xpath)

Parameters

xpath
A string representing an XPath expression.

Returns

An System.Xml.XPath.XPathNodeIterator pointing to the selected node set.

Remarks

The context for the selection is the position of the System.Xml.XPath.XPathNavigator when this method is called. After calling this method, the System.Xml.XPath.XPathNodeIterator returned represents the set of selected nodes. Use XPathNodeIterator.MoveNext method of the System.Xml.XPath.XPathNodeIterator to iterate over the selected node set.

The following C# code iterates over the selected set of nodes.

Example

XPathNodeIterator iterator = nav.Select("/bookstore/book");
while (iterator.MoveNext())
{
    Console.WriteLine(Iterator.Current.Name);
}

The following are important notes to consider when using the XPathNavigator.Select(string) method.

Requirements

Namespace: System.Xml.XPath
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0