I need to import XML data into a MySQL Database using PHP.
There is just one table called 'sales' which has the following columns:
id (INT- PRIMARY)
date (DATE)
customer (VARCHAR)
product (VARCHAR)
count (INT)
Where 'date', 'customer' and 'product' combined make a unique index called 'invoice'.
Not sure if the unique index is relevant in importing the XML but there it is.
The XML file is generated each week with the following format:
<?xml version="1.0" encoding="UTF-8" ?>
<START>
<INVOICE date="2010-09-19">
<INVOICE customer="123" product="nuts" count="1222"/>
<INVOICE customer'"123" product="bolts" count="99"/>
<INVOICE customer="ID10T" product="oil" count="1000"/>
<INVOICE customer'"GG5K" product="water" count="44563"/>
<INVOICE customer="414" product="nuts" count="674"/>
<INVOICE customer'"414" product="water" count="2"/>
</INVOICE>
</START>
I would use 'date' as a starting point but not sure where to go from there.
Any ideas on how i would accomplish this? I imagine I would need to parse the XML, set a pattern to an array in PHP,
but I dont have any experience doing this. Please let me know how I would go about doing this if it's even possible.
Thx,
Melanie