Code example for SAXParser: Parsing XML documents

Methods: getXMLReader, parse

0
            verifyException(e, "No such file or directory");
        } 
 
        // And then with dummy resolver; should work ok now 
        sp = spf.newSAXParser();
        sp.getXMLReader().setEntityResolver(new MyResolver("   "));
        h = new DefaultHandler();
        try { 
            sp.parse(new InputSource(new StringReader(XML)), h);
        } catch (SAXException e) {
            fail("Should not have failed with entity resolver, got ("+e.getClass()+"): "+e.getMessage());
        } 
    } 
 
    /* 
    /////////////////////////////////////////////////////// 
    // Helper classes 
    /////////////////////////////////////////////////////// 
     */ 
 
    static class MyResolver