Select a node : XmlPathNavigator « XML « C# / CSharp Tutorial






using System;
using System.Xml.XPath;
using System.Xml;

class MainClass
{
  static void Main(string[] args)
    {
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(@"c:\books.xml");
    
        XPathNavigator nav = xmlDoc.CreateNavigator();

        Console.WriteLine("Author First Name");
        XPathNodeIterator itrator = nav.Select("descendant::first-name");         
        while( itrator.MoveNext() )
        {
            Console.WriteLine(itrator.Current.Value.ToString());
        }
    }
}








30.23.XmlPathNavigator
30.23.1.XPathNavigator: XPathNodeIterator with comparison
30.23.2.XPathNavigator: Evaluate
30.23.3.Create XPathNavigator object by calling CreateNavigator of XmlDocument
30.23.4.XPathNodeIterator from a select-node statement
30.23.5.Select a node
30.23.6.Get Node information by using XPathNavigator
30.23.7.Move to a child with XPathNavigator
30.23.8.Fast select by ID using XPathNavigator API