Code example for SAXException

0
        ContentHandler contentHandler = new DefaultHandler() {
            @Override 
            public void startElement(String uri, String localName,
                    String qName, Attributes attributes)
                    throws SAXException { 
                throw new SAXException();
            } 
        }; 
        try { 
            parse(SNIPPET, contentHandler);
            fail();
        } catch (SAXException checked) { /* expected */ }
 
        // From endElement(). 
        contentHandler = new DefaultHandler() {
            @Override 
            public void endElement(String uri, String localName,
                    String qName)
                    throws SAXException { 
                throw new SAXException();
            }