0

I am working with the lastfm api and i want to be able to paginate the search results from the artist search.

<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>

I would guess that it would involve taking the totalresults node and dividing it by the items per page. but how do i get the info from totalresults using php?

if this $artists = $xml->results->artistmatches->artist; is how i get the artists, how do i get the correct opensearch node totalresults and items per page?

4

1 回答 1

0

假设您使用 simpleXML:

$total = (int) $xml->results->children("http://a9.com/-/spec/opensearch/1.1/")->totalResults
于 2013-04-01T22:08:35.750 回答