Create XPathDocument from xml file : XPathDocument « XML « C# / CSharp Tutorial






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

public class MainClass  {
  public static void Main() {
      XPathDocument doc = new XPathDocument( "sample.xml" );
      XPathNavigator nav = doc.CreateNavigator();
      XPathExpression xpe = nav.Compile( "//name" );
      XPathNodeIterator ni = nav.Select( xpe );
  
      while ( ni.MoveNext() ) {
          Console.WriteLine(ni.Current.Value);
      }
  }
}








30.22.XPathDocument
30.22.1.Create XPathDocument from xml file
30.22.2.Navigate Xml with XPathNavigator