Java tutorial
//package com.java2s; //License from project: LGPL import java.io.ByteArrayInputStream; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.xml.sax.SAXException; public class Main { public static Element unmarshalDOMElement(String xmlValue) throws SAXException, IOException, ParserConfigurationException { return unmarshalDOMElement(xmlValue.getBytes()); } public static Element unmarshalDOMElement(byte[] input) throws SAXException, IOException, ParserConfigurationException { DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(new ByteArrayInputStream(input)); return doc.getDocumentElement(); } }