public static string FormatXml(string unformattedXML)
{
XmlDocument xd = new XmlDocument();
xd.LoadXml(unformattedXML);
StringBuilder sb = new StringBuilder();
using (StringWriter sw = new StringWriter(sb))
{
using (XmlTextWriter xtw = new XmlTextWriter(sw))
{
xtw.Formatting = Formatting.Indented;
xd.WriteTo(xtw);
}
}
return sb.ToString();
}
Love coding!
No comments:
Post a Comment