3v4l.org

run code in 300+ PHP versions simultaneously
<?php $x = <<<XML <data> <prod id="1"> <layer id="layer_0" imgSRC="data/361_layer_0.png"/> <layer id="layer_1" imgSRC="data/362_layer_0.png"/> <layer id="layer_2" imgSRC="data/363_layer_0.png"/> </prod> <prod id="2"> <layer id="layer_0" imgSRC="data/361_layer_0.png"/> <layer id="layer_1" imgSRC="data/362_layer_0.png"/> <layer id="layer_2" imgSRC="data/363_layer_0.png"/> </prod> </data> XML; $xml = simplexml_load_string($x); // assuming XML in $x $node = $xml->xpath("//prod[@id='2']")[0]; echo htmlentities($node);

preferences:
59.68 ms | 402 KiB | 5 Q