4.2.3 multishop.php
multishop.php makes use of PHP`s event based XML parser. While an XML file could
have been manually parsed, there was nothing to be gained in this instance by reinventing
the wheel. The parser takes much of the work out of traversing an XML file and
extracting values from it, and it also makes it easier to adapt to different XML document
hierarchies. Its key feature is flexibility, which it needs to deal with a HTTP query string
such as:
DESC=
&MAKE=compaq
&MODEL=
&PRICE=2500
&xml%2F1722_KIELTY.xml=on
&xml%2F1437_Killian.xml=on
&xml%2F13755_Killory.xml=on
From the start, one can see that the string is separable into two logical sections. The first
deals with specific search parameters. This example string having come from the smart
form on queries.php, it would seem that the user wishes to browse through all of the
shops in a certain area which sell Compaq computers for not more than 2,500. In this
case, there are three shops which lie in the appropriate area. Assuming that queries.php
has correctly responded to a search for computers or something similar, these should all
be computer shops.
38