Flex XMLListCollection sort on nested tags
- by gauravgr8
Hi all, I have a requirement of sorting the <ename> in the XML with in the branch. The XML goes like this:
<company>
<branch>
<name>finance</name>
<emp>
<ename>rahul</ename>
<phno>123456</phno>
</emp>
<emp>
<ename>sunil</ename>
<phno>123456</phno>
</emp>
<emp>
<ename>akash</ename>
<phno>123456</phno>
</emp>
<emp>
<ename>alok</ename>
<phno>123456</phno>
</emp>
</branch>
<branch>
<name>finance</name>
<emp>
<ename>sameer</ename>
<phno>123456</phno>
</emp>
<emp>
<ename>rahul</ename>
<phno>123456</phno>
</emp>
<emp>
<ename>anand</ename>
<phno>123456</phno>
</emp>
<emp>
<ename>sandeep</ename>
<phno>123456</phno>
</emp>
</branch>
</company>
I tried it with taking XML in XMLList:
var xl:XMLList = new XMLList(branch.ename)
var xlc:XMLListCollection = new XMLListCollection(xl);
then applied sort to the <ename>. I am able to get the sorted but XMLListCollection but the problem is I got the <ename> collection sorted but I need the sorted <ename> in the XML.
I tried with deleting the the item in Collection then adding the sorted list but in that case the <name> is lost.
Please help me out in sorting <ename> or is there any way to specify nested tags in SortField name? Thanks in advance.