Level 8
Try this procedure to get the XML data and recognize the CDATA.
$xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
hi guys
i want get the currency rate from this api :
http://parsijoo.ir/api?serviceType=price-API&query=Currency
but this is xml api and I do not know how can i get data... i was convert this xml to json, With this code :
$response = file_get_contents('http://parsijoo.ir/api?serviceType=price-API&query=Currency');
$xml = simplexml_load_string($response);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
But returns (name, price, change, percent ) values empty what is problem?
Try this procedure to get the XML data and recognize the CDATA.
$xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA);
Please or to participate in this conversation.