我有以下代碼,看看wolfram阿爾法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>
您好!這對我來說可以。記住要查看源代碼,而不僅僅是瀏覽器顯示的內容。 – 2013-05-04 00:58:26