3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $xml=simplexml_load_string(<<<XML <products> <product id="001"> <name>Shirt 1 - Women's</name> <price>12.00</price> <color>blue</color> </product> <product id="002"> <name>Shirt 1 - Men's</name> <price>12.00</price> <color>red</color> </product> <product id="023"> <name>Shirt 12 - Women's</name> <price>15.00</price> <color>purple</color> </product> <product id="024"> <name>Shirt 12 - Men's</name> <price>15.00</price> <color>yellow</color> </product> </products> XML ); foreach($xml->xpath('//product[starts-with(name/text(),"")]') as $product) { echo $product->name; echo "\n"; echo $product->color; echo "\n\n"; }