Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Disable JAXP DTD loading and validation
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
dbf.setNamespaceAware(true);
//one of these pairs of properties will work depending on which xml api impl is in use
dbf.setFeature("http://xml.org/sax/features/namespaces", false);
dbf.setFeature("http://xml.org/sax/features/validation", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment