Mega Code Archive

 
Categories / C# / XML
 

XmlTextWriter Indentation Property gets or sets how many IndentChars to write

using System; using System.IO; using System.Xml; public class Sample {   public static void Main()   {      XmlTextWriter writer = null;      writer = new XmlTextWriter (Console.Out);      writer.Formatting = Formatting.Indented;      writer.Indentation = 4;      writer.WriteStartElement("book");      writer.WriteStartElement("title");      writer.WriteString("C#");      writer.WriteEndElement();      writer.WriteEndElement();      writer.Close();     } }