Read / Write XML in Memory Stream

Use the XmlWriter to write XML to Memory Stream:
MemoryStream stream = new MemoryStream();
XmlWriter writer = XmlWriter.Create(stream);
https://msdn2.microsoft.com/en-us/library/ms162617.aspx 

or you can use the XmlDocument to save xml document to specific stream:
MemoryStream stream = new MemoryStream();
XmlDocument xDocument = new XmlDocument();
xDocument.Save(stream);
https://msdn2.microsoft.com/en-us/library/aa335927(vs.71).aspx

Read the xml document from tream:
MemoryStream stream = new MemoryStream();
XmlDocument xDocument = new XmlDocument();
xDocument.Load(stream);
https://msdn2.microsoft.com/en-us/library/aa335923(VS.71).aspx

Remember to add the following using statements:
using System.IO;
using System.Xml;