John W. Kennedy wrote:
> SAX won't necessarily be /faster/ [than DOM] -- it could be a lot slower. It
> depends on what you're doing.
>
> Are you page-thrashing? If so, than SAX is definitely a good idea.
Another way SAX can really speed things up is that you can use it to handle an
entire XML document in a single pass without huge memory structures to build
and traverse. Back when Java 1.2 first came out I was on a project that used
Java and SAX to parse largish XML documents over the network and it ran like a
bat out of heck. With modern network tech (gigabit LAN, ...), today's
processors and the improvements in Java it would truly scream.
It sounds like the OP's DOM tree is too large to process efficiently. SAX,
correctly used, would almost certainly create a huge speed improvement - like
from 2 hours-infinite down to about a second or two, I would guess.
Like JWK said, it really depends on what you do with the parsed data.
Additional I/O (writing the parsed data to a file or DBMS), large auxiliary
memory structures and other factors could kill the speedup.
-- Lew