Enhance export demo
This commit is contained in:
29
Hcs.WebApp/XmlBeautifier.cs
Normal file
29
Hcs.WebApp/XmlBeautifier.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Hcs.WebApp
|
||||
{
|
||||
internal static class XmlBeautifier
|
||||
{
|
||||
internal static string Beautify(string xml)
|
||||
{
|
||||
var stringBuilder = new StringBuilder();
|
||||
|
||||
var settings = new XmlWriterSettings
|
||||
{
|
||||
OmitXmlDeclaration = true,
|
||||
Indent = true,
|
||||
NewLineOnAttributes = true
|
||||
};
|
||||
|
||||
using (var xmlWriter = XmlWriter.Create(stringBuilder, settings))
|
||||
{
|
||||
var element = XElement.Parse(xml);
|
||||
element.Save(xmlWriter);
|
||||
}
|
||||
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user