[jdom-interest] how is JDOM more lightweight than DOM?

bob bob at accurev.com
Wed Oct 25 08:46:38 PDT 2000


> Newbie question here--reading through the Java/XML book I came across the
> above statement...Don't both schemes store the entire document tree in
> memory?  Just trying to better understand the efficiencies that JDOM
> provides--if someone could explain it would be much appreciated.

JDOM uses java-native collections, and injects more XML semantics 
into the tree than does DOM.  To DOM, everything is Node.  To
JDOM, you have Attribute, Element, and Namespace nodes.

It also uses java.util.List for collections, instead of a 
wrapping of org.w3c.NodeSet, or whatever they use.  The DOM
is supposed to be language-independant, so they didn't
design it with current language-features in mind.  DOM doesn't
let you use Iterators or other things Java programmers have
come to know and love.

If you only program in Java, then I think JDOM is best.  If you're
always jumping languages, then you can learn the DOM API, and it
should theoretically be the same in Java, C++, Perl, or whatnot.

	-bob
	(JDOM bigot)




More information about the jdom-interest mailing list