Enhance export demo

This commit is contained in:
2025-10-02 20:09:43 +09:00
parent f37ea62b8e
commit 2445c23f2e
2 changed files with 38 additions and 5 deletions

View 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();
}
}
}