using System.Xml;
using System.IO;
//...
{
XmlDocument document = new XmlDocument();
string xml = "<?xml version='1.0' encoding='UTF-8'?><Element>" +
"<book ISBN='1-861001-57-5'><title>Pride And Prejudice</title>" +
"<price>19.95</price></book></Element>";
document.LoadXml(xml);
MemoryStream ms = new MemoryStream();
document.Save(ms);
ms.Position = 0;
byte[] buffer = new byte[ms.Length];
ms.Read(buffer, 0, buffer.Length);
ms.Close();
ms.Dispose();
document = null;
Console.WriteLine(Encoding.UTF8.GetString(buffer));
}
//...
}