Java tutorial
//package com.java2s; //License from project: Open Source License import javax.xml.parsers.DocumentBuilderFactory; public class Main { public static final String JAVA_INTERNAL_DBF_CLASS = "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl"; public static final String DBF_SYSTEM_PROPERTY = "javax.xml.parsers.DocumentBuilderFactory"; public static synchronized DocumentBuilderFactory getDocumentBuilderFactory() { String oldDbfImpl = System.getProperty(DBF_SYSTEM_PROPERTY); System.setProperty(DBF_SYSTEM_PROPERTY, JAVA_INTERNAL_DBF_CLASS); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); if (oldDbfImpl != null) { System.setProperty(DBF_SYSTEM_PROPERTY, oldDbfImpl); } else { System.getProperties().remove(DBF_SYSTEM_PROPERTY); } return dbf; } }