Here you can find the source of stringToDOM(String xmlString)
public static Document stringToDOM(String xmlString)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Document; import org.xml.sax.InputSource; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.*; public class Main { public static Document stringToDOM(String xmlString) { try {/*from w w w .j av a2 s . c om*/ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(new InputSource(new StringReader(xmlString))); } catch (Throwable t) { throw new RuntimeException("Error while building document"); } } }