public string XMLDocumentToString (ref XmlDocument doc)
{
MemoryStream stream = new MemoryStream();
XmlTextWriter writer = new XmlTextWriter(stream, null);
writer.Formatting = Formatting.Indented;
doc.Save(writer); //转换
StreamReader sr = new StreamReader(stream, System.Text.Encoding.UTF8);
stream.Position = 0;
string xmlString = sr.ReadToEnd();
sr.Close();
stream.Close();
return xmlString;
}
XmlDocument转为String
最新推荐文章于 2022-03-31 00:27:44 发布