我有以下代码查看 wolfram alpha xml 数据并提取<plaintext>
标签中的答案。它适用于第一个标签,但不适用于答案之后。
代码:
<?php
$url = "http://api.wolframalpha.com/v2/query?input=what+day+is+today&appid=9QA6R9-VGL4AAURHU&format=plaintext&podtitle=Result";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
ob_start();
curl_exec($ch);
curl_close($ch);
$contents = ob_get_contents();
ob_end_clean();
echo $contents;
这是我得到的答案:
Monday, May 3, 2011</plaintext>
</subpod>
</pod>
<sources count='2'>
<source url='http://www.wolframalpha.com/sources/AstronomicalDataSourceInformationNotes.html'
text='Astronomical data' />
<source url='http://www.wolframalpha.com/sources/PeopleDataSourceInformationNotes.html'
text='People data' />
</sources>
</queryresult>