/// <summary> /// 將XmlDocument轉化為string /// </summary> /// <param name="xmlDoc"></param> /// <returns></returns> public string ConvertXmlToString(XmlDocument xmlDoc) { MemoryStream stream = new MemoryStream(); XmlTextWriter writer = new XmlTextWriter(stream, null); writer.Formatting = Formatting.Indented; xmlDoc.Save(writer); StreamReader sr = new StreamReader(stream, System.Text.Encoding.UTF8); stream.Position = 0; string xmlString = sr.ReadToEnd(); sr.Close(); stream.Close(); return xmlString; }
本文URL地址:http://www.bianceng.cn/Programming/csharp/201410/45485.htm