I can display all values in it but I just want to know how to display specific data from this url. Can I display diesel price from this url?
I have tried $getdata->{'gpp:diesel'}
but it display none
Here is the display of the XML API
<gpp:data xmlns:gpp="http://www.globalpetrolprices.com">
<gpp:element>
<gpp:country code="MY">Malaysia</gpp:country>
<gpp:date>2019-05-13</gpp:date>
<gpp:currency>MYR</gpp:currency>
<gpp:diesel>2.18</gpp:diesel>
</gpp:element>
</gpp:data>
Here is the code :
<?php
$url = 'https://www.globalpetrolprices.com/api_gpp.php?cnt=MY&ind=dp&prd=latest&uid=1437&uidc=13fc5a9f3a45102997db4d4698669ac7';
$getdata = file_get_contents($url);
echo "DIESEL PRICE PER LITRE : ".$getdata."<br>";
?>