0

私は 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 を使用して totalresults から情報を取得するにはどうすればよいですか?

これ$artists = $xml->results->artistmatches->artist;がアーティストを取得する方法である場合、正しい opensearch ノードの合計結果とページごとのアイテムを取得するにはどうすればよいですか?

4

1 に答える 1

0

simpleXML を使用すると仮定します。

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