Java tutorial
//package com.java2s; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; public class Main { private static DocumentBuilderFactory documentBuilderFactory; private static DocumentBuilder documentBuilder; public static void refreshDocumentBuilder() { if (documentBuilderFactory == null) { refreshDocumentBuilderFactory(); } try { documentBuilder = documentBuilderFactory.newDocumentBuilder(); } catch (ParserConfigurationException e) { System.out.println("Wrong parser configuration: " + e.getMessage()); } } public static void refreshDocumentBuilderFactory() { documentBuilderFactory = DocumentBuilderFactory.newInstance(); } }