Here you can find the source of stringToXml(final String data)
public static Document stringToXml(final String data)
//package com.java2s; import java.io.Reader; import java.io.StringReader; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.xml.sax.InputSource; public class Main { public static Document stringToXml(final String data) { try {//from w ww. j a va2 s. co m final Reader reader = new StringReader(data); final InputSource source = new InputSource(reader); return DocumentBuilderFactory.newInstance() .newDocumentBuilder().parse(source); } catch (Exception e) { throw new RuntimeException(e); } } }