[jdom-interest] When to use SAXBuilder or DOMBuilder?

Duffey, Keven KDuffey at BUYMEDIA.com
Sun Jun 30 21:18:51 PDT 2002

Hi all,
My application allows for a number of selected XML files. It then loops
through each file, getting "part" of the XML data, displaying it, having
some user interaction, then getting another part of the XML data, and
storing it into a DB along with the user selections take from the first
part. Right now I am using SAXBuilder to do this. I thought I read a
while ago that SAX is great for a one time loop through the XML file,
but if you frequently get the root document in different methods, then
it is not good and DOM is the way to go. I also read that DOM is much
more memory intensive, whereas SAX uses very little memory and reads the
XML much faster. I need to keep memory to a VERY low as our app will run
on machines with 32MB RAM and Windows on it!
To detail a bit more, my app allows a pluggable "format" system. Each
plugin implements how it gets "header" data out of the XML file. That
header data is then used to be displayed and allow the user to match it
up to other DB related items. Then, after that, the next step is to
parse a large chunk of the same XML file, using parts of the user
interacted selections and store it all in our own format in the DB. This
is like a SPOKE program where our program accepts various types of
formats, converting each to our own generic format and storing it. Since
it is possible that hundreds of files could be selected at one time, and
I loop through each file, I figured SAX would be the way to go to avoid
the memory overhead. However, since there are two parts to the parsing
of the same one XML file, what I have done is stored a ref of the XML
file that is parsed for the header data, then later on when the GUI
allows, a different method of the same XML parsing class uses the
already loaded SAXBuilder ref to that XML file. That method also gets
the root, and so on. So is SAX the best way to go, or should I replace
this with DOMBuilder?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020630/6f905b30/attachment.htm

More information about the jdom-interest mailing list