recentpopularlog in

adrianoconnor : code   79

c# - Format XML String to Print Friendly XML String - Stack Overflow
static string PrettyXml(string xml)
{
var stringBuilder = new StringBuilder();

var element = XElement.Parse(xml);

var settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = true;
settings.Indent = true;
settings.NewLineOnAttributes = true;

using (var xmlWriter = XmlWriter.Create(stringBuilder, settings))
{
element.Save(xmlWriter);
}

return stringBuilder.ToString();
}
xml  prettify  code  c#  dotnet 
may 2016 by adrianoconnor

Copy this bookmark:





to read