我正在尝试从 YQL xml 文件中读取和显示一些值。XML 在这里:
http://query.yahooapis.com/v1/public/yql?q=select%20 *%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22YHOO%22)%0A%09%09&diagnostics =false&format=xml&env=http%3A%2F%2Fdatatables.org%2Falltables.env
我正在尝试使用的 PHP 文件如下。我回显的单词正在显示,但 XML 文件中没有变量值。
任何帮助将非常感激!谢谢,詹姆斯
代码:
<?php
$xml = simplexml_load_file('http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22YHOO%22)%0A%09%09&diagnostics=false&format=xml&env=http%3A%2F%2Fdatatables.org%2Falltables.env');
// iterate over query result set
echo '<h2>YHOO</h2>';
$results = $xml->results;
foreach ($results->quote as $q) {
echo '<p>';
echo 'Ask: ' . $q->Ask['ask'];
echo "\n";
echo 'Average Daily Volume: ' . $q->AverageDailyVolume['adv'];
echo '</p>';
}
?>