Code example for DocumentBuilderFactory

Methods: setCoalescingsetIgnoringComments

0
   * @throws javax.xml.parsers.ParserConfigurationException 
   *          If the parser configuration is not supported on your system. 
   */ 
  private static synchronized void initDocBuilderFactory() throws ParserConfigurationException { 
    docBuilderFactory = DocumentBuilderFactory.newInstance();
    docBuilderFactory.setIgnoringComments(true);
    docBuilderFactory.setCoalescing(true);
  } 
 
  /** 
   * Gets a DocumentBuilder to parse a XML property list. As DocumentBuilders are not thread-safe a 
   * new DocBuilder is generated for each request. 
   * 
   * @return A new DocBuilder that can parse property lists w/o an internet connection. 
   */ 
  private static synchronized DocumentBuilder getDocBuilder() throws ParserConfigurationException {
    if (docBuilderFactory == null) {
      initDocBuilderFactory(); 
    } 
    DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Connect your IDE to all the code out there  Get Codota for Java