Wednesday, 12 October 2016

XML : Java : Sort String formatted as XML using attributes

I have a String formatted as XML which I need to sort using attribute key. The result should also be a sorted xml format of String. I am not able to do so.

The XML String format is:

  <Main>    <Node>      <name>ABC</name>      <address>SFO</address>        <contact>John</contact>      <phone>(04115) 30514</phone>    </Node>  <Node>     .....   </Node>   <Node>     .....   </Node>  </Main>    

I need to sort this on the basis of name, address, contact etc. Please help.

No comments:

Post a Comment