Java tutorial
//package com.java2s; import java.io.*; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.*; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; public class Main { public static Document getStringToDocument(String xml) throws TransformerException, ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = dbFactory.newDocumentBuilder(); Document document = builder.parse(new InputSource(new StringReader(xml))); return document; } }