try { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware( true); SAXParser parser = factory.newSAXParser(); XMLReader reader = parser.getXMLReader(); reader.setContentHandler( new SpecialContentHandler()); reader.parse( new Inputsource( "test.xml")); } catch ( ParserConfigurationException e) { e.printStackTrace(); } catch ( SAXException e) { e.printStackTrace(); } catch ( IOException e) { e.printStackTrace(); }