Search code examples
c#xmldocumentpretty-print

XmlDocument OuterXml pretty printed


I've got a XmlDocument and I want to get the Content (OuterXml) as a pretty printed string. How can I do this?

Regards


Solution

  • Assuming I understand this correctly

    using System.Xml.Linq;
    XDocument xDoc = XDocument.Load(@".....\test.xml");
    string xDocString = xDoc.ToString(SaveOptions.None);