OK people. I'm looking to add XML capabilities to my company's product but one question remains: Which parser should be use? I've hear (seen) people praise JDom over JAXP but never explain why. So I'm asking, the great people of the java ranch world, which parser is the best and why? Thank to all of you.
JAXP is a management interface which allows you to "plug in" various DOM or SAX parser implementations. JDOM is a "native Java" document model which wraps round a DOM or SAX parser. If you are writing Java code to create, edit, manipulate XML data, and have no particular requirement for DOM-compatibility at the object and method level, then JDOM is much easier to use than raw DOM. You can still use JAXP to control which parser you choose, or you can tie yourself to a particular parser.
JDOM doesn't constrain the choice of parsers - you can use any parser you want. However since JDOM is built over DOM, your parsing shouldn't be SAX-based method. SAX parsers are always lightweight since they are event-based. DOM parsers offer flexibility of random access, traversal and easy mutators of the XML data, but they consume significant memory since they represent the whole document as an in-memory tree. Having said that, for small XML documents you will really not see a big difference between SAX and DOM. The performance issues become significant only when you're dealing with relatively large documents. 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: Jul 31, 2000
So I'm giving up flexability with JDOM. If I'm looking for a parser to do a wide range of jobs (SAX and DOM), JAXP is my best bet?
U can do both Dom and sax Using JDom and is the best ad simply to use api Hanumanth reddy
<a href="http://www.jobklub.com" target="_blank" rel="nofollow">http://www.jobklub.com</a><br /> 'Add Job To Life'
Joined: Jul 31, 2000
So ease of use is the only reason to go with JDOM? JAXP also provides hooks to use Xalan for transforming. Does JDOM do anything like that? Since Sun is also developing JAXM, XML/Java Binding, and serialization to XML would JAXP be the better choice? Thanks again