Alternative to JAXB for XML parsing

Hector picture Hector · Jul 19, 2014 · Viewed 14.1k times · Source

I am currently using JAXB to parse XML documents, however i need a better performing XML processor.

Better = Faster and decrease memory footprint.

I have to process literally millions of separate XML documents.

I am using websphere application server v7 and java 6.

I have read Stax is the way to go via JAXP, but then i have seen articles saying JAXP is outdated.

If this is true, what are my althernatives to effeciently process millions of XML doucments (each XML doc is beteen 5Kb - 10Kb) without causing my application servers to crash with memory issues.

Answer

Mark Bramnik picture Mark Bramnik · Jul 19, 2014

I think first of all you should track the memory issues. How many of these XML are maintained in memory simultaneously, is it possible to keep only one (or at least some fairly small amount of XMLs) in memory simultaneously? On servers Java processes usually takes at least 1Gb of memory so its not really clear whether the XML parsing is something that makes you process fail.

So I really believe you should work with a profiler here, before coming to conclusions that the XML parser should be changed.

There are a lot of parsers out there, You might try woodstox which is a stax parser. Another option can be xstream If you are looking for something that resembles JAXB, you might want to give a try to a Simple XML parser

Bottom line I believe you should first understand where does the issue exist, and if you resolve it, the chances are that you won't need to switch to another framework at all