From XML to SQL through PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Untouchab1e
Forum Newbie
Posts: 1
Joined: Thu Jun 17, 2010 1:51 pm

From XML to SQL through PHP?

Post by Untouchab1e »

Ok, I am developing an Android application (Java). However, the app creates and upload a .xml file through HTTP Post and I need the data in the xml file to be added to a database. I have little experience with PHP and hoping for (a lot of) help here.

Here is an example xml file

Code: Select all

<?xml version='1.0' encoding='UTF-8' standalone='yes' ?>
<root>
  <ushout_message />
  <data source="bf882ed25e322d48" reply_to="0" />
  <message>Shout out to the world</message>
</root>
Jeg need a .php script which will take in this XML file and put the data into the following database table:

Code: Select all

`id` INT( 6 ) NOT NULL ,
`source` INT( 20 ) NOT NULL ,
`reply` INT( 20 ) NOT NULL ,
`message` VARCHAR(200) NOT NULL , 
PRIMARY KEY ( `id` )
the ID can be generated automatically (auto-increment) so no need to worry about that.



source = data source attribute in the xml file
reply = reply_to in xml file
message = message in xml file.

So wondering if anyone can help me out here?

Kind regards
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: From XML to SQL through PHP?

Post by requinix »

Use SimpleXML for it.
Post Reply