/// <summary>
/// xml帮助类
/// </summary>
public class XmlHelper
{
/// <summary>
/// 格式化xml字符串
/// </summary>
/// <param name="xml"></param>
/// <returns></returns>
public static string XmlToFormate(string xml)
{
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.LoadXml(xml);
System.IO.StringWriter sw = new System.IO.StringWriter();
using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(sw))
{
writer.Indentation = 2;
writer.Formatting = System.Xml.Formatting.Indented;
doc.WriteContentTo(writer);
writer.Close();
}
return sw.ToString();
}
}