Here you can find the source of getDocumentBuilder(boolean secure)
public static DocumentBuilder getDocumentBuilder(boolean secure) throws ParserConfigurationException
//package com.java2s; //License from project: Apache License import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; public class Main { public static DocumentBuilder getDocumentBuilder(boolean secure) throws ParserConfigurationException { String feature;// w w w.j a v a 2 s . c o m DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); feature = "http://xml.org/sax/features/external-general-entities"; factory.setFeature(feature, false); feature = "http://xml.org/sax/features/external-parameter-entities"; factory.setFeature(feature, false); feature = "http://apache.org/xml/features/nonvalidating/load-external-dtd"; factory.setFeature(feature, false); feature = "http://apache.org/xml/features/disallow-doctype-decl"; factory.setFeature(feature, true); factory.setXIncludeAware(false); factory.setExpandEntityReferences(false); factory.setNamespaceAware(true); factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, secure); return factory.newDocumentBuilder(); } }