CSharp examples for System.Xml:XML Format
Format Xml
using System.IO;//from w ww.ja v a 2 s . co m using System.Xml; using System.Text; using System.Collections.Generic; using System; public class Main{ public static string FormatXml(byte[] data) { try { XmlDocument document = new XmlDocument(); document.Load(new MemoryStream(data)); StringWriter output = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(output); writer.Formatting = Formatting.Indented; document.WriteTo(writer); writer.Flush(); output.Flush(); return output.ToString(); } catch (XmlException) { } return ""; } }