I have looked around the web a couple places and I have not found a solution to querying and sorting results from xml files. Basicly what I want to do is select the 'items' where 'parentnav' is greater than 0, then sort those records asc. Xpath seems like it is the way to go.. but I never could get it to do the query without an error, nor could I find out how to sort it. Please help?
This is myxml.php:
<?xml version="1.0" encoding="iso-8859-1" ?>
<pages>
<item>
<parentnav>3</parentnav>
<filename>works.php5</filename>
</item>
<item>
<parentnav>2</parentnav>
<filename>statement.php5</filename>
</item>
<item>
<parentnav>1</parentnav>
<filename>index.php5</filename>
</item>
</pages>
Here is the php code I have now:
$xml = simplexml_load_file("myxml.php");
foreach($xml->item as $item) {
print $item->filename ."\n";
print $item->parentnav ."\n";
}