Java tutorial
//package com.java2s; import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.xml.sax.InputSource; public class Main { private static Document buildDocument(InputStream in) throws Exception { DocumentBuilderFactory factory = null; DocumentBuilder builder = null; Document ret = null; factory = DocumentBuilderFactory.newInstance(); builder = factory.newDocumentBuilder(); ret = builder.parse(new InputSource(in)); return ret; } }