[jdom-interest] Parsing a File using DOMBuilder?

Robert J. Sanford, Jr. rsanford at trefs.com
Tue Jun 11 18:42:21 PDT 2002

This is my first experience with JDOM so bear with me. I tried searching the
interest email archives for "DOM deprecate" but all of the hits were for DOM
and that was a bit much. Anyway...

I just downloaded B8 and started to compile the sample apps and got a
deprecation warning when instantiating a new DOMBuilder with a File object.
So I started looking through the javadocs and from reading the DOMBuilder
javadoc I get the impression that I'm supposed to already have instantiated
an org.w3c.dom.Document to use the DOMBuilder. From looking through the rest
of the javadoc I get the impression that in order to instantiate a
DOMBuilder from an XMLFile I need to use something like:
   SAXBuilder   sax     = new SAXBuilder();
   Document     saxDoc  = sax.build(new File(myXMLFile));
   DOMOutputter out     = new DOMOutputter();
   DOMBuilder   dom     = new DOMBuilder();
   Document     domDoc  = dom.build(out.output(saxDoc));

Is this right? Is there a shorter way to do this? I was thinking from
reading the DOMBuilder sample that:
   DOMBuilder   dom     = new DOMBuilder();
   Document     domDoc  = dom.build(new File(myXMLFile));

was looking to be significantly simpler...


More information about the jdom-interest mailing list