I recently started using JDOM for my XML projects. Compared to parsing and building a document tree with SAX or DOM, JDOM is a blessing in the skies for a Java programmer considering the ease of use. Is there a significant trade-off in performance? Does anyone have any benchmarks comparing SAX and JDOM?
Forgive me if I say the wrong thing, but isn't this comparing apples and oranges. As I understand, SAX and (J)DOM models serve different purposes. I am sure we can get them to work vice-versa, but then IMHO, they are to be applied in different situations. I can understand a comparision between JDOM and someother DOM implementation (if one exists) but JDOM verses SAX ???
Don't don't get me wrong, but just curious as to what others think? regds. - satya
There is a direct relationship between SAX and JDOM because because in the majority of cases you will use SAXBuilder to build a JDOM document. So it is not like comparing apples and oranges...
Joined: Feb 20, 2001
Sorry Madhav, I probably wasn't clear enough when posting my question. What I was getting at is that you can use both SAX/DOM and JDOM to create XML-aware objects (objects that know how to obtain their state from XML sources and present themselves in XML format). JDOM provides much more Java programmer-friendly approach to dealing with document trees as compared with SAX/DOM, so I was wondering what is the magnitude of performance penalty for using JDOM to obtain the object state from XML sources compared to using SAX for the purpose.
JDOM attempts to incorporate the best of DOM and SAX. It's a lightweight API designed to perform quickly in a small-memory footprint. JDOM also provides a full document view with random access but, surprisingly, it does not require the entire document to be in memory. The API allows for future flyweight implementations that load information only when needed. Hope that helps! ------------------ Ajith Kallambella M. Sun Certified Programmer for the Java�2 Platform. IBM Certified Developer - XML and Related Technologies, V1.
Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Joined: Jun 03, 2000
oooh! Thanks for clarifying. Appreciate it. My understanding (read confusion) of JDOM was Java implementation of DOM model and so I thought it had nothing to do with SAX. regds. - satya
The main thing you have to remember about SAX is..the S stands for simple. It is a sequential api...so...when you want to locate a node...it will search the entire tree. JDOM however will load the entire tree into a DOM when parsing..meaning..its in memory and in a hierarchical manor so searching/manipulating/editing is much faster. Hope this helps
Joined: Aug 01, 2008
also...for you hardcore guys out there...the DOM means recursion..