File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes XML and Related Technologies and the fly likes Which one to use? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Which one to use?" Watch "Which one to use?" New topic
Author

Which one to use?

T Bush
Greenhorn

Joined: Jul 31, 2000
Posts: 13
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.


Todd Bush<BR>AIM: RalphWiggam14
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
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.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
T Bush
Greenhorn

Joined: Jul 31, 2000
Posts: 13
Thanks for the info. How about performance? Since JDOM ties itself to a particular parser is it any faster? And would the speed be equal if I used the Xerces parser with JAXP?
Thanks again
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
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).
T Bush
Greenhorn

Joined: Jul 31, 2000
Posts: 13
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?
hanumanth reddy
Ranch Hand

Joined: Jun 12, 2000
Posts: 118
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'
T Bush
Greenhorn

Joined: Jul 31, 2000
Posts: 13
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
mars76
Ranch Hand

Joined: Nov 30, 2000
Posts: 30
Hi,

JDOM is one of the best XML Parsers if not the best..I have used many diffrent parsers like ( Xerces , dom4j ) etc but JDOM is so simple and easy..

regards
Sateesh
[ March 18, 2008: Message edited by: mars76 ]
Daniel Olson
Ranch Hand

Joined: Jan 05, 2001
Posts: 81
JDOM Beta 6 which came out February 15, 2001 supports JAXP.
Hema Menon
Ranch Hand

Joined: Oct 29, 2000
Posts: 569
Hi,
Somewhere I had found an article on how to choose your xml parsers. The article did not cover JDOM. Hopefully by tommorrow I'll be able to post the link.
-hm


~hm
Hema Menon
Ranch Hand

Joined: Oct 29, 2000
Posts: 569
Here's the promised links
http://www.xml-zone.com/articles/sf020101/sf0201-1.asp http://www.xml-zone.com/articles/pm020101/pm020101-1.asp
Thanks,
Hema

Hema Menon
Ranch Hand

Joined: Oct 29, 2000
Posts: 569
Here's the promised links
http://www.xml-zone.com/articles/sf020101/sf0201-1.asp
http://www.xml-zone.com/articles/pm020101/pm020101-1.asp
Thanks
Hema
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Which one to use?