Create XPathDocument from xml file : XPathDocument : XML C# Examples


C# Examples » XML » XPathDocument »

 

Create XPathDocument from xml file









    
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);
            }
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo XML
» XPathDocument