Chapter 10
XML Servers
Goals

We have built Flash software that accesses a server, downloads XML and displays the XML data. On the server, this data exists physically as a file.

In this chapter we will address the server, and how it delivers XML. The chapter primarily serves as an introduction to the concept of middleware and server-side scripting. We will briefly survey the technology and focus on our choice of PHP.

In the remainder of the chapter, we ramp up to speed on PHP and replace our flat files with a transitional model that features two tiers of software.

Introduction

In previous chapters we have experimented with a quiz game. Its database is stored in XML and we have learned a variety of ways to dissect that data and display it to the user.

The actual data is stored on the server as an XML file, which is accessed as a whole and selected from, by the Flash application.

Data storage in XML files is far more sophisticated and robust than storage in simple text files. It is even, in some real senses, an improvement over sophisticated solutions like Generator and Cold Fusion. Unlike those proprietary, closed technologies, an XML service is simple, public and open. A wide variety of tools can operate on the data from many different perspectives.

However a file is just a file. Unless the file is actively alterred, the data does not change. So it has the problem of being static.

Additionally, the file must be loaded as a whole. Any process of selection, for instance, must be done on the client side (in the Flash program) after the entire file is downloaded. This would be a grave inefficiency if, for example, you have software that presents a random "tip of the day" from a heap of three hundred tips. It would be necessary to strain the server, the client and the user’s patience by downloading all three hundred messages so that a single one could be displayed.

A third problem here is security. If the user is supposed to see just a part of a database, it might be for commercial or strategic reasons. It is a compromise of security to send all the data to the user, even if it is supposed to go to a client which only makes certain portions visible. If the file is sent, there are many ways to capture all the data - from simply accessing the XML file directly with a modern browser, to monitoring the IP packet traffic.