Code example for DocumentBuilder

Methods: parse, setEntityResolver, setErrorHandler

0
      final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
      dbf.setNamespaceAware(true);
      dbf.setValidating(false);
 
      final DocumentBuilder db = dbf.newDocumentBuilder();
      db.setEntityResolver(ParserEntityResolver.getDefaultResolver());
      db.setErrorHandler(new LoggingErrorHandler());
      final InputSource input = new InputSource(in);
      return db.parse(input);
    } 
    catch (ParserConfigurationException e)
    { 
      throw new KettlePluginException("Unable to initialize the XML-Parser", e);
    } 
    catch (SAXException e)
    { 
      throw new KettlePluginException("Unable to parse the document.", e);
    } 
    catch (IOException e)
    { 
      throw new KettlePluginException("Unable to read the document from stream.", e);