Input:
<list version="1.0">
Code:
<?php
$request_url = "https://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote";
//Setup cURL Request
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $request_url);
curl_setopt($curl, CURLOPT_TIMEOUT, 130);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl);
curl_close($curl);
$xml = simplexml_load_string(trim($response), "SimpleXMLElement", LIBXML_NOCDATA );
$data = json_decode( json_encode( $xml ), true );
$values = array();
foreach ($xml->resources->resource->field as $text) {
$values[] = $text->__toString();
}
foreach ($xml->resources->resource as $element) {
foreach($element as $key => $val) {
echo "value:".$val."<br>";
}
}
?>
Output:
value:USD/KRW
value:1080.800049
value:KRW=X
value:1525859664
value:currency
value:2018-05-09T09:54:24+0000
value:0
0 comments:
Post a Comment