Find nodes by name : Xml Node : XML C# Examples


C# Examples » XML » Xml Node »

 

Find nodes by name









    
using  System;
using  System.Xml;

public  class  MainClass
{
    [STAThread]
    private  static  void  Main()
    {
        XmlDocument  doc  =  new  XmlDocument();
                doc.Load(@"Sample.xml");


        XmlNodeList  prices  =  doc.GetElementsByTagName("productPrice");
        

        XmlNode  product  =  doc.GetElementsByTagName("products")[0];

        //XmlNode  price  =  ((XmlElement)product).GetElementsByTagName("productPrice")[0];
                
                foreach  (XmlNode  price  in  prices)
        {
            Console.WriteLine(price.ChildNodes[0].Value);
        }
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo XML
» Xml Node