Selects a new set of "records" using the specified XPath expression.
[Visual Basic] Overridable Public Function Select( _ ByVal xpathexpr As Object _ ) As Boolean [C#] public virtual bool Select( object xpathexpr ); [C++] public: virtual bool Select( Object* xpathexpr ); [JScript] public function Select( xpathexpr : Object ) : Boolean;
true if a node set matching the XPath expression was found; otherwise, false.
Exception Type | Condition |
---|---|
ArgumentException | XPath expression contains an error. Or the return type of the XPath expression is not a node set. |
The context for the selection is the position of the navigator when you called this method. After calling this method, you must call MoveToNextSelected to find the first node that matches the specified XPath expression. This makes it easy to write a while loop on MoveToNextSelected- see example 1 below.
You can then use MoveToNextSelected and MoveToPreviousSelected to walk through the set of selected nodes. When you are positioned on a given node, you can also use the MoveToNext method to walk to the sibling of the selected node (which may be outside the selected set). If you do this, the next call to MoveToNextSelected jumps from whereever you were to the next selected node in the previously selected set. In other words, the basic navigation methods are independent of the selected set navigation methods.
Calling Select(xpath) completely resets the current selected set of nodes and forgets any previous selection.
Example | Description |
---|---|
child::* | Navigate to the children of the current node. |
attribute::* | Navigate to the attributes of the current node. |
descendant::* | Navigate to all the descendants of the current node in depth first traversal. |
ancestor::* | Navigate back up the parents of the current node. |
XmlNavigator Class | XmlNavigator Members | System.NewXml Namespace