Here you can find the source of getDocument(String xmlDocument)
public static Document getDocument(String xmlDocument)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayInputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { public static Document getDocument(String xmlDocument) { try {//w w w.j av a 2 s . co m DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); return builder.parse(new ByteArrayInputStream(xmlDocument.getBytes("UTF-8"))); } catch (Exception e) { throw new RuntimeException("Error parsing XML document", e); } } }