List of usage examples for javax.xml.parsers DocumentBuilder isValidating
public abstract boolean isValidating();
From source file:XMLBody.java
/** * Load XML document and parse it into DOM. * //w ww.j a v a2 s . co m * @param input * @throws ParsingException */ public void loadXML(InputStream input) throws Exception { try { // Create Document Builder Factory DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); docFactory.setValidating(false); // Create Document Builder DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); docBuilder.isValidating(); // Disable loading of external Entityes docBuilder.setEntityResolver(new EntityResolver() { // Dummi resolver - alvays do nothing public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { return new InputSource(new StringReader("")); } }); // open and parse XML-file xmlDocument = docBuilder.parse(input); // Get Root xmlElement rootElement = xmlDocument.getDocumentElement(); } catch (Exception e) { throw new Exception("Error load XML ", e); } }