• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • 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
 
and POOF! You're gone! But look, this tiny ad is still here:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic