| home / programming / php / php4xml / chap10 / 3 | [previous] [next] |
|
If our data model is based on XML we'll be querying documents very often. Some examples of the need to query XML are:
Querying an XML document means that we should traverse the XML document looking for particular information; what we do with the information once it is found is beyond the scope of the problem.
Here we'll present a simple example to check how to solve the same problem using different approaches. In this case our example will show an XML file describing cars. This is the XML document:
<cars>
<car>
<type>F1</type>
<brand>Ferrari</brand>
<model>X1</model>
<maxspeed>305</maxspeed>
<hp>800</hp>
</car>
<car>
<type>F1</type>
<brand>Williams</brand>
<model>W89</model>
<maxspeed>298</maxspeed>
<hp>1000</hp>
</car>
<car>
<type>F1</type>
<brand>Brabham</brand>
<model>B01</model>
<maxspeed>311</maxspeed>
<hp>1020</hp>
</car>
</cars>
And the query will be: "Find brand and model of F1 cars that can run at more than 300 kmh".
We have the following options to query an XML document:
| home / programming / php / php4xml / chap10 / 3 | [previous] [next] |
Created: August 26, 2002
Revised: August 26, 2002
URL: http://webreference.com/programming/php/php4xml/chap10/3/3.html