tags:

views:

555

answers:

3

I've used jdom in the past, and have looked briefly at XOM and DOM4j. Each seems to provide essentially the same thing, as they each provide a simplified wrapper over the (very obtuse) standard W3C DOM APIs. I know that JDOM went through some effort to develop a JSR and standardization process at one point, but as far as I know that effort never went anywhere. All of the project appear to be in stasis with little new development in the past several years.

Is there a consensus as to which is the best? Also what are the pros and cons of each?

+5  A: 

I like XOM, because I like the way Elliotte Rusty Harold thinks. Of the ones you mention I belive it's the one that strays away from the DOM standard API:s the most, but I consider that a benefit.

I once implemented a DOM library for Cocoa, and XOM was my inspiration.

I've worked with JDOM as well, and there's absolutely nothing wrong with it, although I do prefer XOM.

Theo
XOM is my choice too. It's simple, produces correct XML, and version 1.2 was just released ;-)
Peter Štibraný
+1  A: 

It all depends on the feature set. If you want to benefit from an XSL Transformation Engine (Like Xalan) or an XPath Engine (Like Jaxen or Saxon) I would recommend sticking to the more popular framework available like Apache Xerces, JDOM.

After that, it's all a matter of taste. I personnally use a W3C compliant ( org.w3c.* ) like Apache Xerces because they are common enough, reasonably fast and well supported by the Java Community.

Of course, if you need blinding speed and do not care about XPath, XQuery or XSL, you can surely find yourself something that is much faster and/or resource-hungry. (i.e. A StAX Implementation)

Shadow_x99
+2  A: 

While dom4j is an old player, we have been using it for a while and haven't regret it yet. Strong features: simplicity, xpath support and others. Weak sides: yet to support java 5.0, but version 2.0 has been finally announced.

Dan
Yep, you're absolutely right about dom4j's good and bad sides. To me, however, it's starting to look like version 2.0 will never come. :( This q is for those who get tired of waiting: http://stackoverflow.com/questions/831865/what-java-xml-library-do-you-recommend-to-replace-dom4j (not that far from this question actually)
Jonik