我從一個返回paginated XML的API中讀取數據。 API的輸出的基本格式是:如何重建分頁的XML文檔?
<candidates.list page="1" next_page="yes">
<candidate />
<candidate />
<candidate />
</candidates.list>
我的代碼是這樣的:
while (TRUE) {
$xml_str = file_get_contents($dest)
$xml = new SimpleXMLElement($xml_str);
// What should I do to append subsequent pages to my first page's XML?
if ($xml['next_page'] == 'yes') {
$dest = $new_destination; // I figure out the next page's API query here
}
else {
break;
}
}
return $xml;
月的快樂第四,謝謝你!
+1從夏天獲得「七月四日快樂」! – 2010-07-04 16:53:48