using System;
using System.Xml;
public class Program {
static void DisplayNode(XmlNode xNode, string sIndent) {
Console.WriteLine("{0}Node: {1}({2})",
sIndent, xNode.Name, xNode.Value);
if (xNode.Attributes != null)
foreach (XmlAttribute xAtt in xNode.Attributes)
Console.WriteLine("{0} Attribute: {1}", sIndent, xAtt.Value);
if (xNode.HasChildNodes)
foreach (XmlNode _xNode in xNode.ChildNodes)
DisplayNode(_xNode, sIndent + " ");
}
static public void Main() {
XmlDocument xDoc = new XmlDocument();
try { xDoc.Load(@"C:\books.xml"); }
catch { }
foreach (XmlNode xNode in xDoc.ChildNodes)
DisplayNode(xNode, string.Empty);
}
}