Java XML Parse Stream parseXML(InputStream is)

Here you can find the source of parseXML(InputStream is)

Description

parse XML

License

Open Source License

Declaration

public static Document parseXML(InputStream is) throws IOException, SAXException 

Method Source Code

//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);
        }
    }
}

Related

  1. parseValue(XMLStreamReader xmlRdr, String elementName)
  2. parseXml(InputStream in)
  3. parseXml(InputStream in)
  4. parseXML(InputStream in)
  5. parseXml(InputStream inputStream, boolean validating)
  6. parseXML(InputStream is, String[] tagNames)
  7. parseXml(InputStream src)
  8. parseXMLFromStream(InputStream stream)
  9. parseXmlInputStream(InputStream inputStream)