Mega Code Archive
Recursively display XmlNode
using System;
using System.Xml;
class MainClass
{
public static void Main()
{
XmlTextReader xtr = new XmlTextReader(@"c:\test.xml");
xtr.WhitespaceHandling = WhitespaceHandling.None;
XmlDocument xd = new XmlDocument();
xd.Load(xtr);
XmlNode xnodDE = xd.DocumentElement;
ChildDisplay(xnodDE, 0);
xtr.Close();
}
private static void ChildDisplay(XmlNode xnod, int level)
{
XmlNode xnodWorking;
String pad = new String(' ', level * 2);
Console.WriteLine(pad + xnod.Name + "(" + xnod.NodeType.ToString() + ": " + xnod.Value + ")");
if (xnod.NodeType == XmlNodeType.Element)
{
XmlNamedNodeMap mapAttributes = xnod.Attributes;
for(int i=0; i