Here you can find the source of getDocument(String xml)
public static Document getDocument(String xml) throws ParserConfigurationException, SAXException, IOException
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class Main { private static DocumentBuilder builder = null; public static Document getDocument(String xml) throws ParserConfigurationException, SAXException, IOException { return getDocumentBuilder().parse(xml); }/*www .j a va 2s. com*/ public static Document getDocument(File xmlfile) throws ParserConfigurationException, SAXException, IOException { return getDocumentBuilder().parse(xmlfile); } private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException { if (builder == null) { DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); builder = domFactory.newDocumentBuilder(); } return builder; } }