大家好,又见面了,我是你们的朋友全栈君。
/// <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;
}
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/150740.html原文链接:https://javaforall.net