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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.