我正在与lastfm api合作,我希望能够从艺术家搜索的搜索结果分页。
<results xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" for="cher">
<opensearch:Query role="request" searchTerms="cher" startPage="1"/>
<opensearch:totalResults>1302</opensearch:totalResults>
<opensearch:startIndex>0</opensearch:startIndex>
<opensearch:itemsPerPage>30</opensearch:itemsPerPage>
我猜这会涉及到获取totalresults节点并将其除以每页的项数。但是如何使用php从totalresult中获取信息呢?
如果这个$artists = $xml->results->artistmatches->artist;
是我获得艺术家的方式,我如何获得正确的开放搜索节点总结果和每页项目?
发布于 2013-04-01 22:08:36
假设您使用simpleXML:
$total = (int) $xml->results->children("http://a9.com/-/spec/opensearch/1.1/")->totalResults
https://stackoverflow.com/questions/15050661
复制