我有一個來自Echoonest API和Spotify URI的歌曲列表,但它增加了更多的歌曲,然後我需要。我只需要其中的一個不是全部,但我想繼續這樣做20次。所以我只想獲得節點內的第一個軌道,然後轉到下一個軌道。只選擇一個節點並在php上移動
Here is the xml file I get the info from
這是我使用PHP:
<iframe src="https://embed.spotify.com/?uri=spotify:trackset:Playlist based on Rihanna:<?php
$completeurl = "http://developer.echonest.com/api/v4/playlist/static?api_key=FILDTEOIK2HBORODV&artist=Rihanna&format=xml&results=20&type=artist-radio&bucket=tracks&bucket=id:spotify-WW";
$xml = simplexml_load_file($completeurl);
$i = 1;
foreach ($xml->xpath('//songs') as $playlist) {
$spotify_playlist = $playlist->foreign_id;
$spotify_playlist2 = str_replace("spotify-WW:track:",'',$spotify_playlist);
echo "$spotify_playlist2,";
if ($i++ == 10) break;
}
?>" width="300" height="380" frameborder="0" allowtransparency="true" style="float: right"></iframe>
如果沒有查看XML或查看輸出結果,您不清楚您的意思。請更新您的問題。 –
兩個具體點要澄清:a)「我只想獲得節點內的第一個軌道,並繼續到下一個節點(''?)和下一個什麼(播放列表?)的第一個軌道? b)你的代碼遍歷''元素,但你的例子只包含一個元素,而它下面沒有''節點;這個代碼實際上工作嗎? –
IMSoP