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