Jump to content

SimpleXML Sorting Question


vicisus_tech

Recommended Posts

I am trying to sort these fields alphabetically by $name - $documents

 

have run past multiple sort methods but none seem to work. I was hoping someone here knew an easy method to do this :)

 

 

xml data:

<database>

<name>Test</name>

<documents>0</documents>

<sections>0</sections>

</database>

<database>

<name>Test2</name>

<documents>100</documents>

<sections>0</sections>

</database>

 

 

current code:

<?php
$request_url = "http://10.100.100.100:9000/a=getstatus";
$xml = simplexml_load_file($request_url) or die("feed not loading");
echo "<table width=\"300\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">\n"; 
echo "  <tr>\n"; 
echo "    <td>Thor Databases</td>\n"; 
echo "    <td>Count\n";
echo $xml->responsedata->databases->num_databases;
echo "    </td>\n"; 
echo "  </tr>\n"; 
foreach ($xml->responsedata->databases->database as $db) {
          echo"<tr><td>",$db->name,"</td><td>",$db->documents,"</td></tr>\n";
  }
echo "</table>\n";
?>

 

Thanks,

 

E

Link to comment
https://forums.phpfreaks.com/topic/210365-simplexml-sorting-question/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.