• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Which one to use?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
T Bush
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
T Bush
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
U can do both Dom and sax Using JDom and is the best ad simply to use api
Hanumanth reddy
 
T Bush
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JDOM Beta 6 which came out February 15, 2001 supports JAXP.
 
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Hema Menon
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
You’ll find me in my office. I’ll probably be drinking. And reading this tiny ad.
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic