Get current value and depth during the XML document reading process : Xml Node : XML C# Examples


C# Examples » XML » Xml Node »

 

Get current value and depth during the XML document reading process









    
using  System;
using  System.Xml;

class  MainClass
{
        static  void  Main(string[]  args)
        {

                XmlTextReader  reader  =  new  XmlTextReader(@"C:\books.xml");

                while  (reader.Read())
                {
                        if  (reader.HasValue)
                        {                                                                              
                                Console.WriteLine("Name:  "+reader.Name);
                                Console.WriteLine("Level  of  the  node:  "  +reader.Depth.ToString());
                                Console.WriteLine("Value:  "+reader.Value);
                        }
                }
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo XML
» Xml Node