3v4l.org

run code in 300+ PHP versions simultaneously
<?php $xml = "<root> <parent> <child name='Child1'>Moi</child> <child name='Child2'>Terve</child> <subparent> <child name='Child3'>Hei</child> </subparent> </parent> <child name='Child4' /> </root>"; $xml = simplexml_load_string( $xml); $result = $xml->xpath('parent/subparent/child'); while(list( , $node) = each($result)) { echo 'b/c: ',$node,"\n"; }

preferences:
38.52 ms | 402 KiB | 5 Q