Code example for XMLReader

Methods: parsesetContentHandlersetFeature

0
        try { 
            SAXParserFactory parserFactory = SAXParserFactory.newInstance();
            parserFactory.setNamespaceAware(true);
            SAXParser saxParser = parserFactory.newSAXParser();
            XMLReader reader = saxParser.getXMLReader();
            reader.setContentHandler(contentHandler);
            try { 
                // Do not load external DTDs (fix #8191) 
                reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
            } catch (SAXException e) {
                // Exception very unlikely to happen, so no need to translate this 
                System.err.println("Cannot disable 'load-external-dtd' feature: "+e.getMessage());
            } 
            reader.parse(new InputSource(in));
            queueIterator = queue.iterator();
            return this;
        } catch (ParserConfigurationException e) {
            // This should never happen ;-) 
            throw new RuntimeException(e);
        } 
Contextual code suggestions in your IDE  Get Codota for Java