Android XML InputStream Parse parse(InputStream is)

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

Description

This will parse an XML stream and create a DOM document.

Parameter

Parameter Description
is The stream to get the XML from.

Exception

Parameter Description
IOException It there is an error creating the dom.

Return

The DOM document.

Declaration

public static Document parse(InputStream is) throws IOException 

Method Source Code

//package com.java2s;
import java.io.IOException;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;

public class Main {
    /**//  w w  w .ja  va  2s  .c o m
     * This will parse an XML stream and create a DOM document.
     *
     * @param is The stream to get the XML from.
     * @return The DOM document.
     * @throws IOException It there is an error creating the dom.
     */
    public static Document parse(InputStream is) throws IOException {
        try {
            DocumentBuilderFactory builderFactory = DocumentBuilderFactory
                    .newInstance();
            DocumentBuilder builder = builderFactory.newDocumentBuilder();
            return builder.parse(is);
        } catch (Exception e) {
            IOException thrown = new IOException(e.getMessage());
            throw thrown;
        }
    }
}

Related

  1. getDocument(InputStream is)
  2. getPullParser(InputStream in, String encoding)
  3. newPullParser(InputStream input)
  4. obtainEncodingStringFromInputStream(InputStream bis)
  5. parse(InputStream in, ContentHandler handler)
  6. parse(InputStream is)
  7. parse(InputStream is, Class cls, List fields, List elements, String itemelement)
  8. parseXml(InputStream is, String elementsTagName)