FormProcessor.FormSubmission.ToXmlDoc C# (CSharp) Method

ToXmlDoc() public method

Serializes the current FormSubmission into an XmlDocument
public ToXmlDoc ( ) : XmlDocument
return System.Xml.XmlDocument
        public XmlDocument ToXmlDoc()
        {
            XmlDocument doc = new XmlDocument();

            using (Stream memoryStore = new MemoryStream())
            {
                XmlSerializer xs = new XmlSerializer(typeof(FormSubmission));
                XmlWriter xmlWriter = new XmlTextWriter(memoryStore, Encoding.Unicode);
                xs.Serialize(xmlWriter, this);

                // reset the read postition so .Load() will start at the beginning (instead of last position written to)
                memoryStore.Position = 0;

                doc.Load(memoryStore);
            }

            return doc;
        }