Use the XmlWriter to write XML to Memory Stream:
MemoryStream stream = new MemoryStream();
XmlWriter writer = XmlWriter.Create(stream);
http://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);
http://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);
http://msdn2.microsoft.com/en-us/library/aa335923(VS.71).aspx
Remember to add the following using statements:
using System.IO;
using System.Xml;
Example:
MemoryStream unzippedFileStream = WCFService1.Classes.Zip.Decompress(zippedFile);
unzippedFileStream.Position = 0;
XmlDocument xDocument = new XmlDocument();
if (unzippedFileStream != null)
{
xDocument.Load(unzippedFileStream);
}
No comments :
Post a Comment