Java tutorial
//package com.java2s; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; public class Main { public static final Object jaxpLock = new Object(); public static DocumentBuilder getJaxpDocBuilder() { try { synchronized (jaxpLock) { System.setProperty("javax.xml.parsers.DocumentBuilderFactory", "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl"); System.setProperty("javax.xml.parsers.SaxParserFactory", "org.apache.xerces.jaxp.SAXParserFactoryImpl"); DocumentBuilderFactory docBuildFactory = DocumentBuilderFactory.newInstance(); docBuildFactory.setAttribute("http://apache.org/xml/features/dom/defer-node-expansion", Boolean.FALSE); docBuildFactory.setNamespaceAware(true); docBuildFactory.setValidating(false); return docBuildFactory.newDocumentBuilder(); } } catch (ParserConfigurationException pce) { throw new RuntimeException(pce.getMessage()); } } }