[jdom-interest] Is BuilderErrorHandler redundant ?

Jason Hunter jhunter at servlets.com
Sun May 11 17:58:46 PDT 2003


"Koller, Shmuel" wrote:
> 
> Parsing piece of code:
> ////////////////////////
> private void init(String xmlMessage, boolean validate) throws Exception
>     {
> 
>         DocumentBuilderFactory factory =
> DocumentBuilderFactory.newInstance();
>         factory.setValidating(validate);
>         try
>         {
>             DocumentBuilder builder = factory.newDocumentBuilder();
>             builder.setErrorHandler(new SAXErrorHandler());
>             xmlDocument = builder.parse(new
> java.io.ByteArrayInputStream(xmlMessage.getBytes(), 0,
> xmlMessage.length()));
>         }
>         catch(SAXException sxe)
>         {
> /////////////////////////////////

That's JAXP code for building DOM, totally unrelated to JDOM.  Why
aren't use using SAXBuilder and forgetting all the above?  The docs page
has links to articles what will show you how to build JDOM documents.

-jh-



More information about the jdom-interest mailing list