How to sort nested nodes xml



I have below menioned xml.



<?xml version="1.0" encoding="UTF-8"?>
<insiders>
<insider>
<linkages>
<linkage>
<owner id="112025">
<namestrings>
<namestring />
</namestrings>
</owner>
<relationshipHistory>
<relationship code="201" />
</relationshipHistory>
</linkage>
</linkages>
</insider>
<insider>
<linkages>
<linkage>
<owner id="100354">
<namestrings>
<namestring>KAITUE RAIMO KUOLINPESĂ„</namestring>
</namestrings>
</owner>
<relationshipHistory>
<relationship code="302">
<from>1998-10-23</from>
</relationship>
</relationshipHistory>
</linkage>
<linkage>
<owner id="126799">
<namestrings>
<namestring />
</namestrings>
</owner>
<relationshipHistory>
<relationship code="204">
<from>2014-09-09</from>
</relationship>
<relationship code="201">
<to>2014-09-08</to>
</relationship>
</relationshipHistory>
</linkage>
</linkages>
</insider>
</insiders>


I want to sort the relationshipHistory node based on code attribute, In mentioned xml code=201 element should first then code=204 after it. can any one please help me how can I do it?


No comments:

Post a Comment