11.1.1
<?xml version="1.0" encoding="US-ASCII" ?><!DOCTYPE customer[<!ENTITY tc "TOP Customer"> ]><customer id="123" status="archived"><firstName>jim</firstName><lastName>Bo</lastName><quote><![CDATA[C#'s operators include:<>&]]>]></quote><notes>Jim Bo is a &tc;</notes></customer>
XmlReaderSettings settings = new XmlReaderSettings{IgnoreWhitespace = true ,DtdProcessing=DtdProcessing.Parse//IgnoreComments=true,//IgnoreProcessingInstructions=true};using (XmlReader reader = XmlReader.Create(str, settings))while (reader.Read()){Console.Write(reader.NodeType.ToString().PadRight(17, '-'));Console.Write('>'.ToString().PadRight(reader.Depth * 6));switch (reader.NodeType){case XmlNodeType.Element:case XmlNodeType.EndElement:Console.WriteLine(reader.Name); break;case XmlNodeType.Text:case XmlNodeType.CDATA:case XmlNodeType.Comment:case XmlNodeType.XmlDeclaration:Console.WriteLine(reader.Value); break;case XmlNodeType.Document:Console.WriteLine(reader.Name+" - "+reader.Value);break;default:break;}//Console.WriteLine(reader.ReadElementContentAsString("customer", ""));}Console.ReadLine();
