If you want to find easly all records satisfying some condition in XML data like
....
<book id="bk101">
<author>Gambardella, Matthew</author>
<title>XML Developer's Guide</title>
<genre>Computer</genre>
<price>44.95</price>
</book>
<book id="bk102">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<genre>Fantasy</genre>
<price>5.95</price>
</book>
...
try example below
<?php
$xmlStr = file_get_contents('data/books.xml');
$xml = new SimpleXMLElement($xmlStr);
$res = $xml->xpath("book/price[.>'40']/parent::*");
print_r($res);
?>
You will see response like:
Array (
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => bk101
)
[author] => Gambardella, Matthew
[title] => XML Developer's Guide
[genre] => Computer
[price] => 44.95
[publish_date] => 2000-10-01
[description] => An in-depth look at creating applications
with XML.
)
...