Trying to extract some data from google stock api. So just trying to extract it.
$t=time();
echo(date("H:i",$t))."<br><br>";
$xml="http://www.google.com/ig/api?stock=KNEBV&stock=FUM1V";
$xml = json_decode(json_encode((array) simplexml_load_file($xml)), 1);
echo '<pre>';
print_r($xml);
echo '</pre>';
?>
That gives me the output below. But I just don't seems to be able to grab any value. I am so lost in the data I don't know which end to start.
I would assume $xml-> finance[0]->symbol would give me "FUM1V" and $xml-> finance[1]->symbol would give me KNEBV but I keep getting blanks whatever combo I try. Ok, it might be a bad example but lost in translation.
Any ideas on how to get "loop" through and print each symbol and some values?
Array
(
[@attributes] => Array
(
[version] => 1
)
[finance] => Array
(
[0] => Array
(
[@attributes] => Array
(
[module_id] => 0
[tab_id] => 0
[mobile_row] => 0
[mobile_zipped] => 1
[row] => 0
[section] => 0
)
[symbol] => Array
(
[@attributes] => Array
(
[data] => FUM1V
)
)
[pretty_symbol] => Array
(
[@attributes] => Array
(
[data] => FUM1V
)
)
[symbol_lookup_url] => Array
(
[@attributes] => Array
(
[data] => /finance?client=ig&q=FUM1V
)
)
[company] => Array
(
[@attributes] => Array
(
[data] => Fortum Oyj
)
)
[exchange] => Array
(
[@attributes] => Array
(
[data] => HEL
)
)
[exchange_timezone] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[exchange_utc_offset] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[exchange_closing] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[divisor] => Array
(
[@attributes] => Array
(
[data] => 2
)
)
[currency] => Array
(
[@attributes] => Array
(
[data] => EUR
)
)
[last] => Array
(
[@attributes] => Array
(
[data] => 14.68
)
)
[high] => Array
(
[@attributes] => Array
(
[data] => 14.77
)
)
[low] => Array
(
[@attributes] => Array
(
[data] => 14.59
)
)
[volume] => Array
(
[@attributes] => Array
(
[data] => 1216170
)
)
[avg_volume] => Array
(
[@attributes] => Array
(
[data] => 1607
)
)
[market_cap] => Array
(
[@attributes] => Array
(
[data] => 13041.22
)
)
[open] => Array
(
[@attributes] => Array
(
[data] => 14.60
)
)
[y_close] => Array
(
[@attributes] => Array
(
[data] => 14.59
)
)
[change] => Array
(
[@attributes] => Array
(
[data] => +0.09
)
)
[perc_change] => Array
(
[@attributes] => Array
(
[data] => 0.62
)
)
[delay] => Array
(
[@attributes] => Array
(
[data] => 0
)
)
[trade_timestamp] => Array
(
[@attributes] => Array
(
[data] => 5 hours ago
)
)
[trade_date_utc] => Array
(
[@attributes] => Array
(
[data] => 20130617
)
)
[trade_time_utc] => Array
(
[@attributes] => Array
(
[data] => 152953
)
)
[current_date_utc] => Array
(
[@attributes] => Array
(
[data] => 20130617
)
)
[current_time_utc] => Array
(
[@attributes] => Array
(
[data] => 212211
)
)
[symbol_url] => Array
(
[@attributes] => Array
(
[data] => /finance?client=ig&q=FUM1V
)
)
[chart_url] => Array
(
[@attributes] => Array
(
[data] => /finance/chart?q=HEL:FUM1V&tlf=12
)
)
[disclaimer_url] => Array
(
[@attributes] => Array
(
[data] => /help/stock_disclaimer.html
)
)
[ecn_url] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[isld_last] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[isld_trade_date_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[isld_trade_time_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[brut_last] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[brut_trade_date_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[brut_trade_time_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[daylight_savings] => Array
(
[@attributes] => Array
(
[data] => true
)
)
)
[1] => Array
(
[@attributes] => Array
(
[module_id] => 0
[tab_id] => 0
[mobile_row] => 0
[mobile_zipped] => 1
[row] => 0
[section] => 0
)
[symbol] => Array
(
[@attributes] => Array
(
[data] => KNEBV
)
)
[pretty_symbol] => Array
(
[@attributes] => Array
(
[data] => KNEBV
)
)
[symbol_lookup_url] => Array
(
[@attributes] => Array
(
[data] => /finance?client=ig&q=KNEBV
)
)
[company] => Array
(
[@attributes] => Array
(
[data] => KONE Corporation
)
)
[exchange] => Array
(
[@attributes] => Array
(
[data] => HEL
)
)
[exchange_timezone] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[exchange_utc_offset] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[exchange_closing] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[divisor] => Array
(
[@attributes] => Array
(
[data] => 2
)
)
[currency] => Array
(
[@attributes] => Array
(
[data] => EUR
)
)
[last] => Array
(
[@attributes] => Array
(
[data] => 65.95
)
)
[high] => Array
(
[@attributes] => Array
(
[data] => 67.00
)
)
[low] => Array
(
[@attributes] => Array
(
[data] => 65.95
)
)
[volume] => Array
(
[@attributes] => Array
(
[data] => 249502
)
)
[avg_volume] => Array
(
[@attributes] => Array
(
[data] => 303
)
)
[market_cap] => Array
(
[@attributes] => Array
(
[data] => 16911.31
)
)
[open] => Array
(
[@attributes] => Array
(
[data] => 66.10
)
)
[y_close] => Array
(
[@attributes] => Array
(
[data] => 66.05
)
)
[change] => Array
(
[@attributes] => Array
(
[data] => -0.10
)
)
[perc_change] => Array
(
[@attributes] => Array
(
[data] => -0.15
)
)
[delay] => Array
(
[@attributes] => Array
(
[data] => 0
)
)
[trade_timestamp] => Array
(
[@attributes] => Array
(
[data] => 5 hours ago
)
)
[trade_date_utc] => Array
(
[@attributes] => Array
(
[data] => 20130617
)
)
[trade_time_utc] => Array
(
[@attributes] => Array
(
[data] => 152952
)
)
[current_date_utc] => Array
(
[@attributes] => Array
(
[data] => 20130617
)
)
[current_time_utc] => Array
(
[@attributes] => Array
(
[data] => 212211
)
)
[symbol_url] => Array
(
[@attributes] => Array
(
[data] => /finance?client=ig&q=KNEBV
)
)
[chart_url] => Array
(
[@attributes] => Array
(
[data] => /finance/chart?q=HEL:KNEBV&tlf=12
)
)
[disclaimer_url] => Array
(
[@attributes] => Array
(
[data] => /help/stock_disclaimer.html
)
)
[ecn_url] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[isld_last] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[isld_trade_date_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[isld_trade_time_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[brut_last] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[brut_trade_date_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[brut_trade_time_utc] => Array
(
[@attributes] => Array
(
[data] =>
)
)
[daylight_savings] => Array
(
[@attributes] => Array
(
[data] => true
)
)
)
)
)