From a499a97cf6324751a7744c979c37084cfbddde34 Mon Sep 17 00:00:00 2001 From: Chris Cameron Date: Thu, 12 Oct 2017 11:53:13 -0400 Subject: [PATCH] Fixing xml formatting --- ICD.Common.Utils/Xml/XmlUtils.cs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/ICD.Common.Utils/Xml/XmlUtils.cs b/ICD.Common.Utils/Xml/XmlUtils.cs index 9615bf0..b49ffc7 100644 --- a/ICD.Common.Utils/Xml/XmlUtils.cs +++ b/ICD.Common.Utils/Xml/XmlUtils.cs @@ -1015,23 +1015,19 @@ namespace ICD.Common.Utils.Xml [PublicAPI] 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(); - - // Load the XmlDocument with the XML. document.LoadXml(xml); - - // Write the XML into a formatting IcdXmlTextWriter document.WriteContentTo(writer); - writer.Flush(); - mStream.Flush(); - // Have to rewind the MemoryStream in order to read its contents. - mStream.Position = 0; - return new IcdStreamReader(mStream).ReadToEnd(); + writer.Flush(); + + return builder.ToString(); } } }