- xpath
- A string representing an XPath expression.
An System.Xml.XPath.XPathNodeIterator pointing to the selected node set.
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.
You can still use any of the System.Xml.XPath.XPathNavigator object's navigation methods to move within the System.Xml.XPath.XPathNavigator. The System.Xml.XPath.XPathNavigator navigation methods are independent of the selected nodes in the System.Xml.XPath.XPathNodeIterator.
Future calls to the XPathNavigator.Select(string) method return a new System.Xml.XPath.XPathNodeIterator object that points to the selected set of nodes that matches the new XPathNavigator.Select(string) call. The two System.Xml.XPath.XPathNodeIterator objects are completely independent of each other.
If the XPath expression requires namespace resolution, use the XPathNavigator.Select(XPathExpression) overload, which takes an System.Xml.XPath.XPathExpression as its argument.
This method has no effect on the state of the System.Xml.XPath.XPathNavigator.