private string FormatXml(string sUnformattedXml) { XmlDocument xd = new XmlDocument(); xd.LoadXml(sUnformattedXml); StringBuilder sb = new StringBuilder(); StringWriter sw = new StringWriter(sb); XmlTextWriter xtw = null; try { xtw = new XmlTextWriter(sw); xtw.Formatting = Formatting.Indented; xtw.Indentation = 1; xtw.IndentChar = '\t'; xd.WriteTo(xtw); } finally { if (xtw != null) xtw.Close(); } return sb.ToString(); }
时间: 2024-12-28 18:14:49