spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / php / php4xml / chap10 / 3 To page 1To page 2current pageTo page 4To page 5To page 6To page 7
[previous] [next]

Professional PHP4 XML, Chapter 10: Putting It Together

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Querying XML

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.

Example

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 To page 1To page 2current pageTo page 4To page 5To page 6To page 7
[previous] [next]

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

Created: August 26, 2002
Revised: August 26, 2002

URL: http://webreference.com/programming/php/php4xml/chap10/3/3.html