Generate Indented Outer Xml - CSharp System.Xml

CSharp examples for System.Xml:XML Format

Description

Generate Indented Outer Xml

Demo Code


using System.Xml.Serialization;
using System.IO;/*from  ww w  .  j av a  2  s  . c  o m*/
using System.Xml;
using System.Text.RegularExpressions;
using System;

public class Main{
        public static string GenerateIndentedOuterXml(string xmlContent)
      {
         StringWriter buffer = new StringWriter();
         XmlTextWriter writer = new XmlTextWriter(buffer);
         writer.Formatting = Formatting.Indented;
         writer.WriteNode(new XmlTextReader(new StringReader(xmlContent)), false);
         return buffer.ToString();
      }
}

Related Tutorials