@ 2016-01-24T02:26:40Z <?php
$xml = '<artists page="1" perPage="100" totalPages="253081" total="25308020">
<artist>
<name>David Bowie</name>
<playcount>151727648</playcount>
<listeners>3969219</listeners>
<mbid>5441c29d-3602-4898-b1a1-b77fa23b8e50</mbid>
<url>http://www.last.fm/music/David+Bowie</url>
<streamable>0</streamable>
<image size="small">
http://img2-ak.lst.fm/i/u/34s/937d62bb145040b9b709319c1e680037.png
</image>
<image size="medium">
http://img2-ak.lst.fm/i/u/64s/937d62bb145040b9b709319c1e680037.png
</image>
<image size="large">
http://img2-ak.lst.fm/i/u/174s/937d62bb145040b9b709319c1e680037.png
</image>
<image size="extralarge">
http://img2-ak.lst.fm/i/u/300x300/937d62bb145040b9b709319c1e680037.png
</image>
<image size="mega">
http://img2-ak.lst.fm/i/u/937d62bb145040b9b709319c1e680037.png
</image>
</artist>
<artist>
<name>The Beatles</name>
<playcount>456495139</playcount>
<listeners>3986977</listeners>
<mbid>b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d</mbid>
<url>http://www.last.fm/music/The+Beatles</url>
<streamable>0</streamable>
<image size="small">
http://img2-ak.lst.fm/i/u/34s/55efc33bcd234fd8a1d65b3d49bf9661.png
</image>
<image size="medium">
http://img2-ak.lst.fm/i/u/64s/55efc33bcd234fd8a1d65b3d49bf9661.png
</image>
<image size="large">
http://img2-ak.lst.fm/i/u/174s/55efc33bcd234fd8a1d65b3d49bf9661.png
</image>
<image size="extralarge">
http://img2-ak.lst.fm/i/u/300x300/55efc33bcd234fd8a1d65b3d49bf9661.png
</image>
<image size="mega">
http://img2-ak.lst.fm/i/u/55efc33bcd234fd8a1d65b3d49bf9661.png
</image>
</artist>
</artists>';
$doc = new DOMDocument();
$doc->loadXML($xml, LIBXML_PARSEHUGE);
$artists = $doc->getElementsByTagName('artist');
foreach($artists as $artist) {
$name = $artist>getElementsByTagName('name')->item(0)->nodeValue;
var_dump($name);
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.27 , 8.2.0 - 8.2.17 , 8.3.0 - 8.3.4 Fatal error: Uncaught Error: Call to undefined function getElementsByTagName() in /in/1W0uQ:56
Stack trace:
#0 {main}
thrown in /in/1W0uQ on line 56
Process exited with code 255 . Output for 5.5.24 - 5.5.35 , 5.6.8 - 5.6.28 Fatal error: Call to undefined function getElementsByTagName() in /in/1W0uQ on line 56
Process exited with code 255 . preferences:dark mode live preview
113.91 ms | 401 KiB | 224 Q