无序XML整理
以下代码能将无序XML内容整理成有序的XML
public static string GetSendXml(string strXml)
{
var doc = new XmlDocument();
doc.LoadXml(strXml);
using (var sw = new StringWriter())
using (var writer = new XmlTextWriter(sw))
{
writer.Indentation = 2; // the Indentation
writer.Formatting = Formatting.Indented;
doc.WriteContentTo(writer);
return sw.ToString(); // 返回格式化后有序的XML
}
}