Frequently, users want to generate XML using information from a database, a method that’s useful for obtaining data when the data changes frequently. Spry can accept data from an XML page or any page that can generate valid XML. You can do this, for instance, using ASP, PHP, or ColdFusion pages and application servers. Adobe provides many code samples that show you how to convert database queries into valid XML. For more information, see https://github.com/adobe/Spry/tree/master/samples/utils/query2xml.html.
To dynamically generate XML using server-side functionality, you should be familiar with the concept of content types. A content type tells the browser what kind of content is on the page. By default, the content type for web pages is set to text/html. This content type tells the browser that it can expect HTML code from the server, and that the page requires no additional processing. This is the most common content type that’s set for HTML pages.
If you are dynamically generating XML content and sending it to a browser using a server-side technology, however, you must tell the browser that the content you are serving is actually XML. To do this, you need to specify a content type in your dynamic page.
For examples of the full code, see https://github.com/adobe/Spry/tree/master/samples/utils/query2xml.html.
One other concern with dynamically generated XML is making sure that the browser (or server) does not cache the data. Browser or server caching can prevent your most recent data from reaching Spry. To prevent this, specify HTTP headers for the following items:
Cache-Control
Expires
Pragma
Consult the preceding link for examples of the full code.