Search code examples
javadomsaxxerces

Sorting XML data by element?


If one needed to be able to display certain elements that contain some certain data and then sort them based on this data. Which would be a better choice for a XML parser, DOM or SAX?

Also can either of these achieve sorting of XML data without the need of storing the data first?


Solution

  • Sorting will require you to read in all of the XML document to memory. So working with a DOM will probably be easier. There are good libraries available that make working with a DOM easier: