老外编的程序(一)--XMLDocument转为String
发表于:2007-06-30来源:作者:点击数:
标签:
static 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;
}
原文转自:http://www.ltesting.net