Java XML Parse Stream parseXMLFromStream(InputStream stream)

Here you can find the source of parseXMLFromStream(InputStream stream)

Description

Parses XML from an input stream.

License

Mozilla Public License

Parameter

Parameter Description
stream Input stream containing valid XML.

Exception

Parameter Description
Exception Unspecified exception.

Return

XML document.

Declaration

public static Document parseXMLFromStream(InputStream stream) throws Exception 

Method Source Code

//package com.java2s;
/**/*from w  ww. j a va2s.  com*/
 * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
 * If a copy of the MPL was not distributed with this file, You can obtain one at
 * http://mozilla.org/MPL/2.0/.
 * 
 * This Source Code Form is also subject to the terms of the Health-Related Additional
 * Disclaimer of Warranty and Limitation of Liability available at
 * http://www.carewebframework.org/licensing/disclaimer.
 */

import java.io.InputStream;

import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

public class Main {
    /**
     * Parses XML from an input stream.
     * 
     * @param stream Input stream containing valid XML.
     * @return XML document.
     * @throws Exception Unspecified exception.
     */
    public static Document parseXMLFromStream(InputStream stream) throws Exception {
        Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(stream);
        stream.close();
        return document;
    }
}

Related

  1. parseXML(InputStream in)
  2. parseXml(InputStream inputStream, boolean validating)
  3. parseXML(InputStream is)
  4. parseXML(InputStream is, String[] tagNames)
  5. parseXml(InputStream src)
  6. parseXmlInputStream(InputStream inputStream)
  7. parseXmlInputStream(InputStream inputStream)
  8. parseXMLResource(final InputStream inputStream)