Created
November 10, 2014 18:43
-
-
Save tekguy/0f702e2e7beb3d4fb8c2 to your computer and use it in GitHub Desktop.
An extension to prettyify your xml document with proper indentation
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
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