Java tutorial
//package com.java2s; import java.io.IOException; import java.io.InputStream; 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 { static DocumentBuilderFactory domBuilderFactory; public static synchronized Document inputStream2XML(InputStream streamedXml) throws SAXException, IOException, ParserConfigurationException { synchronized (domBuilderFactory) { DocumentBuilder builder = domBuilderFactory.newDocumentBuilder(); return builder.parse(streamedXml); } } }