using System;
using System.IO;
using System.Xml;
public class Sample {
private const String filename = "items.xml";
public static void Main() {
XmlTextReader reader = null;
try {
reader = new XmlTextReader(filename);
reader.WhitespaceHandling = WhitespaceHandling.None;
while (reader.Read()) {
switch (reader.NodeType) {
case XmlNodeType.Element:
Console.Write("<{0}>", reader.Name);
break;
case XmlNodeType.Text:
Console.Write(reader.Value);
break;
case XmlNodeType.ProcessingInstruction:
Console.Write("{0} {1}?>", reader.Name, reader.Value);
break;
case XmlNodeType.Comment:
Console.Write("", reader.Value);
break;
case XmlNodeType.XmlDeclaration:
Console.Write("");
break;
case XmlNodeType.Document:
break;
case XmlNodeType.DocumentType:
Console.Write(" break;
case XmlNodeType.EntityReference:
Console.Write(reader.Name);
break;
case XmlNodeType.EndElement:
Console.Write("{0}>", reader.Name);
break;
}
}
}finally {
if (reader!=null)
reader.Close();
}
}
}