Here you can find the source of getNewDocumentBuilder()
private static DocumentBuilder getNewDocumentBuilder()
//package com.java2s; //License from project: Apache License import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; public class Main { private static DocumentBuilder getNewDocumentBuilder() { try {//w w w. j a v a 2 s. co m final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setAttribute("http://xml.org/sax/features/namespaces", true); factory.setAttribute("http://xml.org/sax/features/validation", false); factory.setAttribute("http://apache.org/xml/features/nonvalidating/load-dtd-grammar", false); factory.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); factory.setNamespaceAware(true); factory.setIgnoringElementContentWhitespace(true); factory.setValidating(false); factory.setIgnoringComments(false); final DocumentBuilder builder = factory.newDocumentBuilder(); return builder; } catch (final ParserConfigurationException e) { throw new RuntimeException("Failed to create DocumentBuilder", e); } } }