This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XML String sorting issue . Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML String sorting issue ." Watch "XML String sorting issue ." New topic

XML String sorting issue .

Karn Kumar
Ranch Hand

Joined: Aug 06, 2009
Posts: 145

Hi All ,

Actually i have XML string in one format as below

The xml should be in the format as below i.e. can consider first tag <PQR> for sorting .

Is there any mechanism/Utility in java i can operate on xml string the format 1 given above ?
Karn Kumar
Ranch Hand

Joined: Aug 06, 2009
Posts: 145

Also I have document object , If can perform any sorting operation . Let me know your suggestion.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 468
Normally, one can do it through a simple xsl transformation. The central piece is an identity transformation whereas the template matching element node is slightly modified for the purpose of the required sorting. This is the typical look of it.

If you've not much of an idea of xslt, read up its general way of thinking in terms of templates or functional programming and its general settings, and apply the above. You can of course even integrate xslt with your existing document object inside your programming code as you said you have it already.
Karn Kumar
Ranch Hand

Joined: Aug 06, 2009
Posts: 145

Thanks g tsuji ,

I am new to xsl , but will check for solution provided.

I agree. Here's the link:
subject: XML String sorting issue .
Similar Threads
Query on HashMap
Math.Random() query
extracting image binary data from file
How to refresh a StringBuffer object for creating a HashMap object
for loop demo