I have been asked to parse a simple file which is stored as an XML file, the data is to be then put into a mysql database.
However I have absolutely no clue what to
I personally like the normal XMl formatting so I changed it since its a bit more readable but this is how you can use it:
$xmlstr = <<
1
Cornetto
1.20
Traditional Cornetto
2
Smarties
1.00
Smarties Icecream
1
242
pounds
2
11
pounds
XML;
Handling part:
$xml = new SimpleXMLElement($xmlstr);
echo 'single value:
';
echo $xml->products->product[0]->id; // get single value
echo '
';
//Loop trough multiple products
echo 'multiple values:
';
foreach($xml->products->product as $product)
{
echo $product->id.' - ';
echo $product->name.' - ';
echo $product->price.' - ';
echo $product->description;
echo '
';
}