RE: [PHP] Re: Sorting parsed XML
Okay, that's neat and I get what you're saying with xml_process() to handle this. >From what I'm reading, it would not allow this sort of procedure, but please let me know otherwise: == echo "" . $ServerName; if ($ServerType) { echo " (" . $ServerType . ")\n"; } else { echo "\n"; } if ($ServerStatus == "Down") { echo "" . $ServerStatus . "\n"; } else { echo "" . $ServerPopulation . "\n"; } == So, what would print in the first and 2nd column would depend upon the results of one of two variables (1st column relies upon if there's a $ServerType or not, 2nd column relies upon the $ServerStatus not being "Down"). My problem is still my own, I can't get it so that when I parse, the information is placed into an array that can then be used for sorting. This would be ideal for me as I plan on reading from more than one .xml (different structures as well) on the same page if I can get this to work. I guess what I'm asking for is a method to parse information into an array and then sort it by any part of the array. I attempted the $ServerArray[$this->ServerName][$this->ServerStatus] = $data in the parse section (where $data = current node value), but it didn't work. Again, thanks for all your help so far and in advance for any help you can provide. ~Confused PHP user > From: @ Edwin [mailto:[EMAIL PROTECTED]] > > "Geoff Hankerson" <[EMAIL PROTECTED]> wrote: > > > You don't need to do client-side transformation (although you could > > check user agent and do it client-side if the browser supports it). > > You can use Php's XSLT functions see the manual for more info. > > > > I was just suggesting this as a potential option. It may not be > > appropriate in this situation. I don't really know enough about the > > programming challenge we are looking at to say for sure > > I see. I thought you were saying that use XSLT and access the > xml file directly--my apologies. > > Anyway, _that_ is certainly a potential option... :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Sorting parsed XML
"Geoff Hankerson" <[EMAIL PROTECTED]> wrote: > You don't need to do client-side transformation (although you could > check user agent and do it client-side if the browser supports it). > You can use Php's XSLT functions see the manual for more info. > > I was just suggesting this as a potential option. It may not be > appropriate in this situation. I don't really know enough about the > programming challenge we are looking at to say for sure I see. I thought you were saying that use XSLT and access the xml file directly--my apologies. Anyway, _that_ is certainly a potential option... :) - E -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Sorting parsed XML
You don't need to do client-side transformation (although you could check user agent and do it client-side if the browser supports it). You can use Php's XSLT functions see the manual for more info. I was just suggesting this as a potential option. It may not be appropriate in this situation. I don't really know enough about the programming challenge we are looking at to say for sure @ Edwin wrote: "Geoff Hankerson" <[EMAIL PROTECTED]> wrote: 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. Perhaps... but not all browsers support it. Anyway, you can also select the nodes in PHP and you can sort them as well. And you can do more than that... ;) - E -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Sorting parsed XML
"Geoff Hankerson" <[EMAIL PROTECTED]> wrote: > 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. Perhaps... but not all browsers support it. Anyway, you can also select the nodes in PHP and you can sort them as well. And you can do more than that... ;) - E -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: Sorting parsed XML
Unavailable as I am reading an XML file produced by another web site and it dynamically updates the information on the sheet every 5 minutes or so. At least to my knowledge of what XSLT can do. > From: Geoff Hankerson [mailto:[EMAIL PROTECTED]] > > 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Sorting parsed XML
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" <[EMAIL PROTECTED]> 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 ''; before this and $xml_parser = xml_parser_create(); ...[snip code]... after this xml_parser_free($xml_parser); echo ''; 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 's or '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]... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Sorting parsed XML
Hello, "Chris" <[EMAIL PROTECTED]> 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 ''; before this and > $xml_parser = xml_parser_create(); ...[snip code]... after this > xml_parser_free($xml_parser); echo ''; 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 's or '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]... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php