Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.xml.sax.InputSource; import javax.xml.parsers.DocumentBuilderFactory; import java.io.StringReader; public class Main { public static Document stringToXML(String xmlString) throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); Document document = null; try { document = factory.newDocumentBuilder().parse(new InputSource(new StringReader(xmlString))); } catch (Exception e) { e.printStackTrace(); } return document; } }