Skip to content

Instantly share code, notes, and snippets.

@tekguy
Created November 10, 2014 18:43
Show Gist options
  • Save tekguy/0f702e2e7beb3d4fb8c2 to your computer and use it in GitHub Desktop.
Save tekguy/0f702e2e7beb3d4fb8c2 to your computer and use it in GitHub Desktop.
An extension to prettyify your xml document with proper indentation
public static class XmlDocumentPrettyExtension
{
public static string Prettyify(this XmlDocument xmlDocument)
{
var stringWriter = new StringWriter(new StringBuilder());
var xmlTextWriter = new XmlTextWriter(stringWriter) { Formatting = Formatting.Indented };
xmlDocument.Save(xmlTextWriter);
return stringWriter.ToString();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment