IT.COM

XML feed to MySQL table

Spaceship Spaceship
Watch

TheWatcher

Founder, MAJ.comTop Member
Impact
992
I search google but no success, not giving up yet!

I need to know best practice to auto-upload the xml feed I received from partners to my MySQL database.

Everyday, I received this XML file e.g. 'testdata.xml'. I add these xml values to the table manually everyday, I need to automate this process.
<?xml version="1.0" encoding="utf-8"?>
<elements>
<device>0-123456</device>
<unixTime>1034268516</unixTime>
<location>N</location>
<data length="9" source="pc" encoding="hex">0xC0560D72DA4AB2445A</data>
</elements>

I need to create a php script to open all xml files (1testdata.xml, 2testdata.xml, 3testdata.xml, etc)and insert these to my Mysql database table using the same field name .e.g device, unixtime, location, and data.

My initial assessment is to create a php script, to read the xml file, capture the xml data, then insert to my MySQL table. And set up a cron to run the script every hour.

Creating the php script to read the xml file, inserting the data to MySQL is where I'm stuck. Any idea where to begin?

Thank you,
em @ king.net
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Well I would start with making a script to upload the file.
Then make one that opens it and uses preg_match for each thing you needed to extract. Then a run a mysql insert command for each one. But this is assuming the data will stay the same each time and wont change.
 
0
•••
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back