mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-04-13 20:47:24 +00:00
Fixing xml formatting
This commit is contained in:
parent
f7842116a4
commit
a499a97cf6
1 changed files with 7 additions and 11 deletions
|
|
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue