Here you can find the source of parse(String source)
public static Document parse(String source) throws ParserConfigurationException, SAXException, IOException
//package com.java2s; import java.io.ByteArrayInputStream; 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 { public static Document parse(String source) throws ParserConfigurationException, SAXException, IOException { DocumentBuilder builder = DocumentBuilderFactory.newInstance() .newDocumentBuilder();/*from w w w.ja v a 2s . com*/ return builder.parse(new ByteArrayInputStream(source.getBytes())); } public static Document parse(File source) throws ParserConfigurationException, SAXException, IOException { DocumentBuilder builder = DocumentBuilderFactory.newInstance() .newDocumentBuilder(); return builder.parse(source); } }