What’s the ideal way of generating XML without creating and saving a file?
I’m thinking of using an ASP.NET page with code behind to generate the markup as XML.
Is this possible? Or would you have an alternative way?
I have a flash component that reads an XML file and I need to dynamically generate this file. I don’t have write permission so I won’t have the ability to create and save a file.
I was thinking of having an application page that grabs the data and provide property methods to generate the xml on the Settings.xml.aspx page with Settings.xml.aspx.cs codebehind.
Thanks.
The easiest way is to use
System.Xml.XmlDocumentorSystem.Xml.Linq.XDocumentto build up the document. Both can be streamed out to theResponse.OutputStream.The smoothest approach (especially if you turn off buffering) is simply to create an
XmlTextWriterround theResponse.OutputStream. This is a forward only approach to generate XML but if the output is large it means you need less memory and content starts to arrive at the client earlier.