3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = '<?xml version="1.0" encoding="utf-8" ?> <note> <to> <form>D</form> <heading>E</heading> <body>F</body> </to> <to> <form>A</form> <heading>B</heading> <body>C</body> </to> </note>'; $xml = simplexml_load_string($data); foreach ($xml->to as $to) { if ($to->form == 'A') { // našel jsem <to>, ve kterém je <form>A</form> // a tady s ním můžu pracovat echo "heading: ".$to->heading."\nbody: ".$to->body; } }

preferences:
56.51 ms | 408 KiB | 5 Q