System.IO.MemoryStream ms = new System.IO.MemoryStream();
xmlDoc.Save(ms);
System.IO.StreamReader sr = new System.IO.StreamReader(ms, System.Text.Encoding.UTF8);
ms.Position = 0;
string xmlString = sr.ReadToEnd();
转载于:https://www.cnblogs.com/zhang-wenbin/p/6723582.html