I have been told that I will NEED to use SAX to do this because the files will be quite large in size, is this correct?
Joined: Nov 14, 2005
Robert, It depends. If files are really large, then yes SAX will be better. Since SAX parser won't read entire XML document into memeory but it reads as it parses so there you can see the advantage.
But the other side of the SAX is, it parses sequentially. if you are looking for few particular nodes, then it wastes lot of processor time by tranvelling all the nodes sequentially.
But using DOM will get you the required nodes without touching every element sequentially. But the problem with DOM is, it reads the entire document in the memory and builds a tree structure before it starts processing.
So your decision depends on How big the file is going to be and the order of the processing.
Every DOM parser uses SAX parser to build the DOM tree. Your argument of SAX parser wastes more time to access a few node does NOT hold any water.
However, there are many DOM or other parsers actually don't read the entire XML file into memory, they are using the Lazy-Initialization Pattern. They only expand the node when it is needed. In that case, the parser is better.
As far as I know, JDOM was using the Lazy-Initialization Pattern, even though JDOM stopped developing since 2004.