Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.io.InputStream; public class Main { public static Document xml2doc(InputStream inputStream) throws IOException, SAXException, ParserConfigurationException { return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream); } }