I am trying to read the book.xml file provided as an example on the MSDN website.
You can iterate over the titles if you change the XPath expression to select all title nodes:
XPathDocument document = new XPathDocument(@"c:\tmp\smpl5.xml");
XPathNavigator navigator = document.CreateNavigator();
XPathNodeIterator nodes = navigator.Select("/bookstore/book/title");
foreach (XPathNavigator item in nodes)
{
Console.WriteLine(item.Value);
}
Note that you don't need to create an XmlDocument if you don't plan to modify the document. Using an XPathDocument is usually more light-weight.