Here you can find the source of parse(String text)
static public Document parse(String text)
//package com.java2s; //License from project: Apache License import java.io.StringReader; import javax.xml.parsers.DocumentBuilder; import org.w3c.dom.Document; import org.xml.sax.InputSource; public class Main { static public Exception exception = null; static private DocumentBuilder parser = null; static public Document parse(String text) { Document document = null; exception = null;/*from www . j a v a 2s . c om*/ try { document = riskyParse(text); } catch (Exception e) { exception = e; } return document; } public static synchronized Document riskyParse(String text) throws Exception { InputSource is = new InputSource(new StringReader(text)); return parser.parse(is); } }