- simplexml_load_string: documentation ( source)
<?php
$xml=simplexml_load_string(<<<XML
<products>
<product>
<name>Shirt 1 - Women's</name>
<price>12.00</price>
<color>blue</color>
</product>
<product>
<name>Shirt 1 - Men's</name>
<price>12.00</price>
<color>red</color>
</product>
<product>
<name>Shirt 12 - Women's</name>
<price>15.00</price>
<color>purple</color>
</product>
<product>
<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 $product1)
{
echo $product1->name;
echo "\n";
echo $product1->color;
echo "\n\n";
}