Code example for XMLReader

Methods: parse, setContentHandler, setFeature

0
        try { 
            SAXParserFactory saxfactory = SAXParserFactory.newInstance();
            saxfactory.setValidating(false);
            SAXParser parser = saxfactory.newSAXParser();
            xmlReader = parser.getXMLReader();
            xmlReader.setContentHandler(this);
            xmlReader.setFeature("http://xml.org/sax/features/namespaces",
                                 false); 
            xmlReader
                    .setFeature("http://xml.org/sax/features/namespace-prefixes",
                                false); 
        } catch (Exception e) {
            throw new RepositoryConfigurationException("Internal SAX error while " 
                    + "preparing for Method Map datastream parsing: " 
                    + e.getMessage());
        } 
        try { 
            xmlReader.parse(new InputSource(in));
        } catch (Exception e) {
            throw new ObjectIntegrityException("Error parsing Method Map datastream" 
                    + e.getClass().getName() + ": " + e.getMessage());
        } 
    }