?
Solved

PHP Sorting Results XML

Posted on 2007-12-06
6
Medium Priority
?
2,429 Views
Last Modified: 2012-05-05
Hello, Can anyone let me know what is the best way to parse and sort results in an XML feed through PHP. Thanks.
0
Comment
Question by:vfetty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 5

Expert Comment

by:nacker2000
ID: 20421504
Hi,

Have a look at SimpleXML: http://uk3.php.net/simplexml
0
 

Author Comment

by:vfetty
ID: 20422036
Thanks, I have seen that before but not sure what half that stuff is and how do you sort results with it?
0
 
LVL 5

Expert Comment

by:nacker2000
ID: 20422160
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.
0
How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

 

Author Comment

by:vfetty
ID: 20422222
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.
0
 
LVL 5

Accepted Solution

by:
nacker2000 earned 375 total points
ID: 20422277
The SimpleXML will work with raw XML, provided it is formatted correctly. What will the sort function be used for?

The reason I ask is that once you have the XML parsed you use PHP to do your sorting if its just for something simple like outputing certain values.
0
 

Author Comment

by:vfetty
ID: 20422317
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.
0

Featured Post

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question