Created
November 8, 2011 01:11
-
-
Save yetanotherchris/1346732 to your computer and use it in GitHub Desktop.
format xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
/// Formats the provided XML so it's indented and humanly-readable. | |
/// | |
/// <param name="inputXml" />The input XML to format. | |
/// | |
public static string FormatXml(string inputXml) | |
{ | |
XmlDocument document = new XmlDocument(); | |
document.Load(new StringReader(inputXml)); | |
StringBuilder builder = new StringBuilder(); | |
using (XmlTextWriter writer = new XmlTextWriter(new StringWriter(builder))) | |
{ | |
writer.Formatting = Formatting.Indented; | |
document.Save(writer); | |
} | |
return builder.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment