Java tutorial
//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 { public static DocumentBuilder getDocumentBuilder(boolean NamespaceAwareness) throws ParserConfigurationException { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(NamespaceAwareness); // Unfortunately we can not ignore whitespaces without a schema. // So we use the NdLst workaround for now. //domFactory.setValidating(true); //domFactory.setIgnoringElementContentWhitespace( true ); domFactory.setAttribute("http://apache.org/xml/features/dom/include-ignorable-whitespace", Boolean.FALSE); return domFactory.newDocumentBuilder(); } }