Code example for DocumentBuilder

Methods: parse, setErrorHandler

0
 
                builder = factory.newDocumentBuilder();
                builder.setErrorHandler(ipReference);
            } 
 
            Document doc = builder.parse(input);
            nodes = doc.getElementsByTagName(rootTag);
        } catch (Exception e) {
            throw new ParsingException("Error tring to parse " + rootTag + "Type", e);
        } 
 
        if (nodes.getLength() != 1)
            throw new ParsingException("Only one " + rootTag + "Type allowed "
                    + "at the root of a Context doc"); 
 
        return nodes.item(0);
    } 
 
    /** 
     * Standard handler routine for the XML parsing. 
     *