Code example for DocumentBuilderFactory

Methods: newDocumentBuilder, setNamespaceAware, setValidating

0
 
    private static Document getDummyDocument( ) {
        try { 
            if ( dbf == null ) {
                dbf = DocumentBuilderFactory.newInstance();
                dbf.setNamespaceAware( true );
                dbf.setValidating( false );
            } 
            db = dbf.newDocumentBuilder();
 
            DOMImplementation dim = db.getDOMImplementation();
            d = dim.createDocument("http://java.sun.com/jaxp/xpath",
                "dummyroot", null); 
            return d;
        } catch ( Exception e ) {
            e.printStackTrace();
        } 
        return null; 
    }