Xpath more search examples
$string=’ <?xml version="1.0" encoding="UTF-8"?> <products> <product category="software"> <sku>soft32323</sku> <name>Widget Reporting</name> <price>4550</price> </product> <product category="software"> <sku>soft32323</sku> <sub_category>Business Analysis</sub_category> <name>Pro Reporting</name> <price>2350</price> </product> </products>’; $xml = simplexml_load_string($string); // Search by tag name $products = $xml->xpath("/products/product[sku=’soft32323′]/name"); print_r($products); // Search by tag attribute $products = $xml->xpath("/products/product[@category=’software’ and price > 2320]"); print_r($products);