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