I want to sort un-ordered XML files so that two files can be comparable. XML file should be sorted based on first outermost tag and then inner tags. I want some generic code. For Example:
My XML file is :
<xn:rootElement>
<subs:Parent id="2">
<subs:Child1 id="2">
<attributes>
<attribute1></attribute1>
<attribute2></attribute2>
<attributes>
</subs:Child1>
</subs:Parent>
<subs:Parent id="2">
<subs:Child1 id="1">
<attributes>
<attribute1></attribute1>
<attribute2></attribute2>
<attributes>
</subs:Child1>
</subs:Parent>
</xn:rootElement>
I want the following result, as parent id is same it is sorted on base of child element.
<xn:rootElement>
<subs:Parent id="2">
<subs:Child1 id="1">
<attributes>
<attribute1></attribute1>
<attribute2></attribute2>
<attributes>
</subs:Child1>
</subs:Parent>
<subs:Parent id="2">
<subs:Child1 id="2">
<attributes>
<attribute1></attribute1>
<attribute2></attribute2>
<attributes>
</subs:Child1>
</subs:Parent>
</xn:rootElement>
Need to check every possibility , if parenet id is same then sort on base of child id.
Note: Size of XMLs is very Large.
Thanks a lot in advance.