Sorting XML file by attribute
Posted
by LibraRocks
on Stack Overflow
See other posts from Stack Overflow
or by LibraRocks
Published on 2010-05-06T16:49:46Z
Indexed on
2010/05/06
17:58 UTC
Read the original article
Hit count: 182
Hi, I have a following XML code:
<Group>
<GElement code="x">
<Group>
<GElement code="x">
<fname>a</fname>
<lname>b</lname>
</GElement>
<GElement code ="f">
<fname>fa</fname>
</GElement>
</Group>
</GElement>
<GElement code ="f">
</GElement>
</Group>
I would like to have the output sorted by "code" like:
<Group>
<GElement code ="f">
</GElement>
<GElement code="x">
<Group>
<GElement code ="f">
<fname>fa</fname>
</GElement>
<GElement code="x">
<fname>a</fname>
<lname>b</lname>
</GElement>
</Group>
</GElement>
</Group>
The depth of the tree can be endless i.e. the GElement can have another Group and so on.
Any ideas?
© Stack Overflow or respective owner