Difference in performance between Stax and DOM parsing

Posted by Fazal on Stack Overflow See other posts from Stack Overflow or by Fazal
Published on 2010-03-26T03:10:03Z Indexed on 2010/03/26 3:13 UTC
Read the original article Hit count: 471

Filed under:
|

I have been using DOM for a long time and as such DOM parsing performance wise has been pretty good. Even when dealing with XML of about 4-7 MB the parsing has been fast. The issue we face with DOM is the memory footprint which become huge as soon as we start dealing with large XMLs.

Lately I tried moving to Stax (Streaming parsers for XML) which are supposed top be second generation parsers (reading about Stax it said its the fastest parser now). When I tried stax parser for large XML for about 4MB memory footprint definitely reduced drastically but time take to parse entire XML and create java object out of it increased almost by 5 times over DOM.

I used sjsxp.jar implementation of Stax.

I can deuce to some extent logically that performance may not be extremely good due to streaming nature of the parser but a reduction of 5 time (e.g. DOM takes about 8 seconds to build object for this XML, whereas Stax parsing took about 40 seconds on average) is definitely not going to be acceptable.

Am I missing some point here completely as I am not able to come to terms with these performance numbers

© Stack Overflow or respective owner

Related posts about java

Related posts about xmlparser