When overridden in a derived class, moves the System.Xml.XPath.XPathNavigator object returned by the XPathNodeIterator.Current property to the next node in the selected node set.
true if the System.Xml.XPath.XPathNavigator object moved to the next node; false if there are no more selected nodes.
The System.Xml.XPath.XPathNodeIterator object is positioned on the first node in the selected node set only after the initial call to the XPathNodeIterator.MoveNext method. The node set is created in document order. Therefore, calling the XPathNodeIterator.MoveNext method moves to the next node in document order.
There are two ways to iterate over an System.Xml.XPath.XPathNavigator collection by using the System.Xml.XPath.XPathNodeIterator class.
One way is to use the XPathNodeIterator.MoveNext method and then call XPathNodeIterator.Current to get the current System.Xml.XPath.XPathNavigator instance, as in the following example:
code reference: XPathNavigatorMethods#55
Another way is to use a foreach loop to call the XPathNodeIterator.GetEnumerator method and use the returned IEnumerator interface to enumerate the nodes, as in the following example:
code reference: XPathNavigatorMethods#56
You should either use the XPathNodeIterator.MoveNext method and XPathNodeIterator.Current or use the XPathNodeIterator.GetEnumerator method. Combining these two approaches can cause unexpected results. For example, if the XPathNodeIterator.MoveNext method is called first, and then the XPathNodeIterator.GetEnumerator method is called in the foreach loop, the foreach loop will not start enumerating the results from the beginning of the collection, but from the position after the XPathNodeIterator.Current method.