Java tutorial
//package com.java2s; 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.xml.sax.SAXException; public class Main { public static Document GetDocumentFromBytes(byte[] data) { //DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl",null); DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = null; Document doc = null; java.io.ByteArrayInputStream bais = new java.io.ByteArrayInputStream(data); try { db = dbf.newDocumentBuilder(); doc = db.parse(bais); } catch (ParserConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SAXException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { bais.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } return doc; } }