My advice is to use the wonderful encyclopedia available to you called "The Internet".

I went to Google and typed in:  sort xml AS3

The first 4 results have the exact code you need to do this.

The Internet: Helping people find answers, one search at a time.



On May 21, 2009, at 7:25 AM, Dominic Tancredi wrote:

Hey All!

I have a weird xml sorting question. I'm retrieving a folder hierarchy and displaying it in flex using a tree (yes yes, flex, but it's an actionscript question). However, I'm requested to make the results alphabetical. So that's either XSL server-side, or sort the results in actionscript.

I was able to put together actionscript to sort the top level of XML (by creating objects in an array, sorting the array by the attribute, then creating a new xml based on the array), but figuring out the recursion to sort each of its children is... driving me nuts. Do any of you have advice on sorting hierarchical xml data?

XML is like this:

<node label="RootDir">
        <node label="firstdir"></node>
        <node label="seconddir"></node>
        <node label="thirddir">
                <node label="subdir1">
                <node label="subdir2">
                <node label="subdir3">
        </node>
</node>

I can show my sortXML code if you have any q's.

Dom
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to