Java tutorial
//package com.java2s; import java.io.ByteArrayInputStream; import java.io.InputStream; import org.w3c.dom.*; import javax.xml.parsers.*; public class Main { public static Element GetXmlDocFromStr(String xmlStr) { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null; try { db = dbf.newDocumentBuilder(); } catch (ParserConfigurationException pce) { pce.printStackTrace(); } Document doc = null; try { InputStream inputStream = new ByteArrayInputStream(xmlStr.getBytes()); doc = db.parse(inputStream); } catch (Exception e) { e.printStackTrace(); } return (Element) doc.getDocumentElement(); } }