javaxmlfilter

Filtering XML nodes in Java | XSLT or Parser


I have a big XML returned by SAP. Of this, I need only few nodes, may be 30% of the returned data.

After googling, I got to know that I can filter the nodes in either of the ways:

  1. Apply XSLT templates - Have seen some nice solutions, which I want, in this site only.

  2. Using a parser - use JDOM or SAX parser.

Which is the efficient way to "filter XML nodes"?


Solution

  • SAX parser will be the fastest and most efficient (in that you don't need to read the entire document into memory and process it).

    XSLT will be probably a terser solution since all you need is an identity transform (to copy the input document) with a few templates to copy out the bits you want.

    Personally I'd go with the SAX parser.