Overload that accepts xml as text

Dec 11, 2009 at 9:29 AM
Edited Dec 11, 2009 at 10:33 AM

Could you provide an overload of the Build method that accepts the xml data itself as a string, instead of the file name?

This would be useful for a merge functionality, where you would collect xml data on-the-fly (in memory), and then generate a document with it.
It would take away the extra step of saving the data in a temporary file first.

Thanks in advance,

Jos

Coordinator
Dec 11, 2009 at 5:59 PM

You can write to a  MemoryStream to hold the data in memory. This is exactly what the webservice does. Check Service.svc.cs:

            using (MemoryStream dataXmlStream = new MemoryStream())
            {
                using (StreamWriter sw = new StreamWriter(dataXmlStream))
                {
                    sw.Write(request.dataXML);
                    sw.Flush();
                    dataXmlStream.Seek(0, SeekOrigin.Begin);

                    DocBuilder docBuilder = GetDocBuilder(request.Template);
                    docBuilder.Build(dataXmlStream,
                        request.dataXMLNamespacePrefix,
                        request.dataXMLNamespaceURI,
                        outputStream,
                        renderCulture,
                        (request.Validation == BuildValidation.Enabled));
                }
            }
Dec 12, 2009 at 7:39 AM

OK, thanks!

Jos