public static Stream GetDocumentStream(System.Xml.XmlDocument xmlDoc) { Stream output = new MemoryStream(); if (xmlDoc != null) { xmlDoc.Save(output); } Streaming.Reset(ref output); return(output); }