Here you can find the source of parse(String document)
public static Document parse(String document) throws SAXException, IOException
//package com.java2s; // modify it under the terms of the GNU General Public License import java.io.ByteArrayInputStream; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class Main { private static DocumentBuilder builder = null; public static Document parse(java.io.InputStream in) throws SAXException, IOException { Document result = null;/* w w w . ja v a 2 s. co m*/ synchronized (builder) { result = builder.parse(in); } return result; } public static Document parse(String document) throws SAXException, IOException { return parse(new ByteArrayInputStream(document.getBytes())); } }