Created
January 19, 2012 16:13
-
-
Save Nilzor/1640865 to your computer and use it in GitHub Desktop.
String to String XML pretty Printer in C#
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 string PrettyPrint(string xml) | |
{ | |
XmlDocument doc = new XmlDocument(); | |
doc.LoadXml(xml); | |
var sb = new StringBuilder(); | |
var sw = new StringWriter(sb); | |
var xw = new XmlTextWriter(sw); | |
xw.Formatting = Formatting.Indented; | |
doc.WriteTo(xw); | |
return sb.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment