mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-16 13:15:07 +00:00
Fixing xml formatting
This commit is contained in:
@@ -1015,23 +1015,19 @@ namespace ICD.Common.Utils.Xml
|
|||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public static string Format(string xml)
|
public static string Format(string xml)
|
||||||
{
|
{
|
||||||
using (IcdMemoryStream mStream = new IcdMemoryStream())
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
using (IcdStringWriter stringWriter = new IcdStringWriter(builder))
|
||||||
{
|
{
|
||||||
using (IcdXmlTextWriter writer = new IcdXmlTextWriter(mStream, Encoding.UTF8))
|
using (IcdXmlTextWriter writer = new IcdXmlTextWriter(stringWriter))
|
||||||
{
|
{
|
||||||
IcdXmlDocument document = new IcdXmlDocument();
|
IcdXmlDocument document = new IcdXmlDocument();
|
||||||
|
|
||||||
// Load the XmlDocument with the XML.
|
|
||||||
document.LoadXml(xml);
|
document.LoadXml(xml);
|
||||||
|
|
||||||
// Write the XML into a formatting IcdXmlTextWriter
|
|
||||||
document.WriteContentTo(writer);
|
document.WriteContentTo(writer);
|
||||||
writer.Flush();
|
|
||||||
mStream.Flush();
|
|
||||||
|
|
||||||
// Have to rewind the MemoryStream in order to read its contents.
|
writer.Flush();
|
||||||
mStream.Position = 0;
|
|
||||||
return new IcdStreamReader(mStream).ReadToEnd();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user