これは、musicbrainz が返す xml の例です (アーティスト「Absynthe Minded」と曲「Moodswing Baby」の場合):
<metadata xmlns="http://musicbrainz.org/ns/mmd-2.0#" xmlns:ext="http://musicbrainz.org/ns/ext#-2.0">
<recording-list offset="0" count="3">
<recording ext:score="100" id="580d3e6f-6b2a-4f2c-bb06-a73486de50b8">
<title>Moodswing Baby</title>
<length>230706</length>
<artist-credit>...</artist-credit>
<release-list>
<release id="f183e8a3-5326-44c9-8ab3-00a2dbb74caf">
<title>Absynthe Minded</title>
<status>Official</status>
<release-group type="Album"/>
<date>2009</date>
<country>BE</country>
<medium-list>...</medium-list>
</release>
<release id="fccd0f03-30e5-44ac-8825-a61ad8b25442">...</release>
<release id="b3873ea0-0ed3-48f1-9703-4f5302460d0e">...</release>
<release id="b68fb38c-5a5a-4d24-bd41-2c50945cef39">...</release>
</release-list>
<puid-list>...</puid-list>
<isrc-list>...</isrc-list>
</recording>
<recording ext:score="100" id="359c27e3-5153-445e-aa66-71d8152d19e4">...</recording>
<recording ext:score="31" id="e9e4628a-61ff-4dd7-8fbb-a8d655d29a5a">...</recording>
</recording-list>
</metadata>
現在、私のウェブサイトのアーティスト名の横にその国「BE」を印刷しようとしています。
<?php
$xml = simplexml_load_file("http://www.musicbrainz.org/ws/2/recording?query=moodswing%20baby%20AND%20artist:absynthe%20minded");
$info = $xml->recording-list->recording[1]->release-list->release[1]->country;
echo $info;
?>
同じ方法を使用して、last.fm のデータベース (xml も) から曲とアーティストの情報を取得しますが、これでは機能しないようです (T_OBJECT_OPERATOR、'(' エラーが予想されます)。[1] を削除しようとしましたしかし、結果はありません。
その国を取得して印刷する方法はありますか? ありがとうございました!