我正在尝试解析具有以下格式的XML:
<lfm status="ok">
<album>
<name>Babel</name>
<artist>Mumford And Sons</artist>
<id>310716066</id>
<mbid/>
<url>
http://www.last.fm/music/+noredirect/Mumford+And+Sons/Babel
</url>
<releasedate></releasedate>
<image size="small">http://userserve-ak.last.fm/serve/34s/85199619.jpg</image>
<image size="medium">http://userserve-ak.last.fm/serve/64s/85199619.jpg</image>
<listeners>4621</listeners>
<playcount>151324</playcount>
<tracks></tracks>
<toptags>
<tag>
<name>indie</name>
<url>http://www.last.fm/tag/indie</url>
</tag>
</toptags>
</album>
</lfm>
但是当我这样做时:
//Chamar a API do Last.FM
$album_response = file_get_contents("http://ws.audioscrobbler.com/2.0/?method=album.getinfo&api_key=9ba08c332660c8e23d8612e296696236&artist=$artista&album=$album");
//Criar um DOMDocument
$xml= new DOMDocument('1.0', 'ISO-8859-1');
$xml->loadXML($album_response);
//Ver se o álbum existe
$encontrou_album = $xml->getElementsByTagName("lfm")->item(0)->getAttribute("status");
最后一行不起作用。有关如何检索该属性的任何想法?