Generally any object model (DOM, dom4j, JAXB etc.) is going to be slower than SAX in general, since SAX doesn't create an object model, it just passes through XML events. Most object models, including dom4j, are generally built on top of SAX, so its hard to be faster than SAX.
There's an interesting performance paper here:- http://www-106.ibm.com/developerworks/xml/library/x-injava/index.html We'll hopefully have support for lazy parsing using XPP soon which would mean that depending on how much of the document you look at, there could be times where dom4j is actually faster than SAX. I'd always recommend people actually benchmark their code and analyse which part of their application actually needs to be tuned first before diving in and trying to optimise things because they think they should. While we're on the subject of optimisation, here's a few classic quotes I dug up (ain't the web great ;-)... "We should forget about small efficiencies, say about 97% of the time: premature optimisation is the root of all evil." Donald Knuth Rules of Optimisation: Rule 1: Don't do it. Rule 2 (for experts only): Don't do it yet. M.A. Jackson James ----- Original Message ----- From: "Brain, Jim" <[EMAIL PROTECTED]> To: "DOM4J Mailing List (E-mail)" <[EMAIL PROTECTED]> Sent: Monday, November 12, 2001 8:32 PM Subject: [dom4j-user] SAX vs DOM4J > Has anyone done any benchmarking of SAX (Xerces or Aelfred) versus DOM4J? I > know DOM is slower, but I like the ease of DOM4J. Is rewriting my code (for > performance) into SAX going to save me all that much? > > Jim > > > Jim Brain, [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > "Researching tomorrow's decisions today." > (319) 369-2070 (work) > Systems Architect, Individual ITS, Life Investors Insurance Company of > America > > > _______________________________________________ > dom4j-user mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/dom4j-user > _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user
