Here you can find the source of parseXML(InputStream is)
public static Document parseXML(InputStream is) throws IOException, SAXException
//package com.java2s; /************************************************************************* **/*from w w w. j a v a 2 s. c o m*/ ** Copyright (C) 2007 Jan de Visser. All rights reserved. ** ** This file may be used under the terms of the GNU General Public ** License version 2.0 as published by the Free Software Foundation ** and appearing in the file LICENSE.GPL included in the packaging of ** this file. Please review the following information to ensure GNU ** General Public Licensing requirements will be met: ** http://www.trolltech.com/products/qt/opensource.html ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ****************************************************************************/ import java.io.IOException; import java.io.InputStream; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class Main { private static DocumentBuilderFactory s_dom_factory = DocumentBuilderFactory.newInstance(); public static Document parseXML(InputStream is) throws IOException, SAXException { try { Document ret = s_dom_factory.newDocumentBuilder().parse(is); return ret; } catch (ParserConfigurationException ex) { throw new RuntimeException("Configuration Exception parsing XML: " + ex); } } }