XPathNavigator : XmlPathNavigator : XML C# Examples


C# Examples » XML » XmlPathNavigator »

 

XPathNavigator









    
using  System;
using  System.Collections.Generic;
using  System.Text;
using  System.Xml;
using  System.Xml.XPath;

class  MainClass
{
        static  void  Main(string[]  args)
        {
                string  xml  =  "<Order>"  +
                                                "<Item>"  +
                                                        "<Description>widget  part</Description>"  +
                                                        "<Price>1.9</Price>"  +
                                                "</Item>"  +
                                                "<Item>"  +
                                                        "<Description>Another  widget</Description>"  +
                                                        "<Price>5.2</Price>"  +
                                                "</Item>"  +
                                        "</Order>";

                XmlDocument  doc  =  new  XmlDocument();
                doc.LoadXml(xml);

                XPathNavigator  nav  =  doc.CreateNavigator();
                XPathNodeIterator  nodes  =  nav.Select("/Order/Item[Price>10]/Description");

                while  (nodes.MoveNext())
                {
                        Console.WriteLine("Item  {0}  has  a  price  greater  than  10",nodes.Current.Value);
                }
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo XML
» XmlPathNavigator