Michiel
06-18-2006, 12:51 AM
Hi,
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):
<invoices>
<invoice id="01" client="1">
<rule>
<description>
Description 1
</description>
<price>
10
</price>
</rule>
<rule>
<description>
Description 2
</description>
<price>
20
</price>
</rule>
</invoice>
</invoices>
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):
<clients>
<client id="1">
<name>
Client name
</name>
<contact>
Contact
</contact>
<address>
Street
</address>
</client>
</clients>
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
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):
<invoices>
<invoice id="01" client="1">
<rule>
<description>
Description 1
</description>
<price>
10
</price>
</rule>
<rule>
<description>
Description 2
</description>
<price>
20
</price>
</rule>
</invoice>
</invoices>
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):
<clients>
<client id="1">
<name>
Client name
</name>
<contact>
Contact
</contact>
<address>
Street
</address>
</client>
</clients>
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