您的位置:首页 > 编程语言 > C#

C# 将XmlDocument转化为string

2015-01-05 08:27 375 查看
/// <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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: