Link to home
Start Free TrialLog in
Avatar of vfetty
vfetty

asked on

PHP Sorting Results XML

Hello, Can anyone let me know what is the best way to parse and sort results in an XML feed through PHP. Thanks.
Avatar of nacker2000
nacker2000

Hi,

Have a look at SimpleXML: http://uk3.php.net/simplexml
Avatar of vfetty

ASKER

Thanks, I have seen that before but not sure what half that stuff is and how do you sort results with it?
Well it's easy to use if you are loading in an XML structure:

$data = '<movie>
                 <title>value</title>
              </movie>';

/* parse as xml */
$xml_data = simplexml_load_string($data);

And then to read out a value you do:

/* get data */
$value = $xml_data->movie->title;

The link I posted above shows some basic examples and there are lots of other sites that explain how to use it. Once you have read a few examples it will become easy to use.
Avatar of vfetty

ASKER

I do not see a sort function there, please keep in mind I'm new to this and I do not need a full blown example but a sorting example would be nice.  Plus I am dealing with raw XML not RSS. Thanks for you help.
ASKER CERTIFIED SOLUTION
Avatar of nacker2000
nacker2000

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vfetty

ASKER

The sort function will be like page 1, 2, 3, 4, 5, 6 by alpha so because the results are way to much to put on one return (about 120 results from the XML file) wanted to break them up into 10 per page.