XPathDocument doc = new XPathDocument("books.xml"); XPathNavigator nav = doc.CreateNavigator(); // Move to the first book node nav.MoveToFirstChild(); // Move to the next sibling book node nav.MoveToNext();
XPathDocument doc = new XPathDocument("employees.xml"); XPathNavigator nav = doc.CreateNavigator(); // Move to the first employee node nav.MoveToFirstChild(); do { // Process the current employee node ... } while (nav.MoveToNext());This example loads an XML file containing a list of employees, creates an XPathNavigator from the document, moves to the first employee node, and then iterates through all the employee nodes using a do-while loop. The System.Xml.XPath namespace is part of the System.Xml.dll library.