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