Generates the indented outer XML. - CSharp System.Xml

CSharp examples for System.Xml:XML Format

Description

Generates the indented outer XML.

Demo Code


using System.Xml.Serialization;
using System.IO;// w w  w  .  ja  v  a  2  s. c om
using System.Xml;
using System.Text.RegularExpressions;
using System;

public class Main{
        /// <summary>
        /// Generates the indented outer XML.   
        /// </summary>
        /// <param name="xmlContent">Content of the XML.</param>
        /// <returns></returns>
        /// <remarks></remarks>
      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