using System;
using System.IO;
using System.Xml;
public class Sample
{
public static void Main()
{
XmlReader reader = XmlReader.Create("book.xml");
reader.MoveToContent();
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;
}
}
}
}