Re: Re: Sorting parsed XML
| From: | Geoff Hankerson | Date: | Mon, 25 Nov 2002 18:27:02 +0000 |
| Subject: | Re: Re: Sorting parsed XML | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-125972@lists.php.net to get a copy of this message | ||
This seems to me to be more easily handled by XSLT. (Not the only option but a good one).
XSLT lets you select only the nodes you want and also sort them as well.
@ Edwin wrote:
Hello, "Chris" <cgoodno@comcast.net> wrote:I'm trying to write PHP code that will not only parse the XML but also allow me to sort the parsed information by the values parsed.I'm not sure if I really understand but let me try... ...[snip code]... Adding echo '<table border="1">'; before this and$xml_parser = xml_parser_create();...[snip code]... after thisxml_parser_free($xml_parser);echo '</table>'; shows a good view that you have a table with two columns. If you'd like to sort these, then I think you might be able to do something like this: 1. Instead of printf()'ing your <td>'s or <tr>'s inside the class/function, why don't you try "putting" it inside an array? (Maybe with array_push() or something.) Then, 2. If you already have an array, perhaps you can use one of the functions here for sorting: http://www.php.net/manual/en/ref.array.php HTH, - E ...[snip]...