I have a local server , where i am receiving xml files. The xml files are received just fine but i have problem on how to pass my XML file into my database.
I retrieve the xml file simple as that :
$xml_post = file_get_contents('php://input');
The xml files i receive looks like this :
<city>
<id>1081</id>
<name>athens</name>
<country>Greece</country>
<info>etc etc etc</info>
</city>
I have manually created a database with phpmyadmin with the exact same nodes so i can save everything correctly.
Now i want to insert what i am getting in the database with mysql_query. Something like this :
mysql_query("INSERT INTO cities (id, city ,country , info)
VALUES (4 , 'athens' , 'greece' , 'etc etc etc'");
But which are the variables that i have stored my xml to use them as values in the statement above? How can i parse the xml file that i have to store all the nodes in variables and then pass them correctly to the database?