Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.InputStream; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.xml.sax.InputSource; public class Main { public static Document parseStream(final InputStream xmlis) { try { return DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(xmlis)); } catch (final Exception e) { throw new RuntimeException(e); } } }