Java tutorial
//package com.java2s; //License from project: Apache License import org.w3c.dom.*; import org.xml.sax.InputSource; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import java.io.StringReader; public class Main { public static Document convertStringToDocument(String domStr) { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder; try { builder = factory.newDocumentBuilder(); Document doc = builder.parse(new InputSource(new StringReader(domStr))); return doc; } catch (Exception e) { e.printStackTrace(); } return null; } }