Although the apache digester is popular today and also benefit us a lot, but sometimes we still need to validate or parse the xml base on the DTD, for the static validate / parse (most of the case, it is the procedure of reading a configuration File of the web application received a xml from others and you need to specify the different DTD base on the different case, that is common in a J2EE project) The following API will handle with such case For the SAX SAXParserFactory factory = SAXParserFactory.newInstance ();. factory. setValidating (true); // do not forgot this SAXParser parser = factory.newSAXParser (); XMLReader reader = parser.getXMLReader (); reader.setEntityResolver (## you own error handler ##); reader.setErrorHandler (## You Own Error Handler ##); for the Dom DocumentBuilderFactor y factory = DocumentBuilderFactory.newInstance () factory.setValidating (true); // never forgot this DocumentBuilder builder = factory.newDocumentBuilder (); builder.setEntityResolver ((## you own error handler ##);); builder.setErrorHandler ( (## error handler ##););