I have been using the DOM for a long time, and so the DOM parsing was pretty good. Even with XML about 4-7 MB in size, parsing was quick. The problem we are facing with the DOM is the amount of memory that becomes huge as soon as we start working with large XML documents.
Recently, I tried moving to Stax (stream parsers for XML), which are supposed to be the second generation parser (reading about Stax, which it called the fastest parser). When I tried the Stax parser for large XML for about 4 MB of memory, certainty was drastically reduced, but the time to parse all XML and create a Java object from it increased almost 5 times compared to the DOM.
I used the sjsxp.jar implementation for Stax.
To some extent, I can logically prove that performance may not be very good due to the streaming nature of the parser, but it is 5 times reduced (for example, the DOM takes about 8 seconds to create an object for this XML, while Stax parsing took about 40 seconds on average) will definitely not be acceptable.
I missed some point here completely, since I cannot put up with these performance numbers
source share