View Full Version : SimpleXML: can I perform 'queries'?

06-18-2006, 01:51 AM

I'm looking into the possibilities of xml to store the data for a project I'm currently working on. I started out with SimpleXML, because it seems to me that I won't be doing any complicated stuff. However I can't figure out how to 'perform queries' on the xml-data with SimpleXML.

First let me explain a little bit about my datamodel. I'm working on an invoice application. In invoices.xml I store all the invoices, like so (simplified for reference):

<invoice id="01" client="1">
Description 1
Description 2

As you can see, I set the client-id as an attribute of the invoice tag. This id obviously refers to a certain client, who's contact information is stored in another xml file (clients.php):

<client id="1">
Client name

Now I want to be able to connect the two files. When I view the complete invoice, I want to retrieve the appropriate contact information based on the client-id.

How do I do such a thing? Is it possible to do this with SimpleXML or are the thing I want to do not that *simple*?

Thanx in advance. -Michiel

ralph l mayo
06-19-2006, 12:34 AM
Looks like you're trying to implement a relational database in XML. Don't do that.