Android XML InputStream Parse LoadXml(InputStream stream)

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

Description

Load Xml

Declaration

private static Document LoadXml(InputStream stream) throws Exception 

Method Source Code

//package com.java2s;
import java.io.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;

public class Main {
    public static Document LoadXml(String xml) throws Exception {
        // create...
        ByteArrayInputStream stream = new ByteArrayInputStream(
                xml.getBytes());/*from   ww  w.  ja  v a 2s.c o m*/
        try {
            return LoadXml(stream);
        } finally {
            if (stream != null)
                stream.close();
        }
    }

    private static Document LoadXml(InputStream stream) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory
                .newInstance();
        factory.setNamespaceAware(true);

        // builder...
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document doc = builder.parse(stream);

        // return...
        return doc;
    }
}

Related

  1. readSetXml(InputStream in)
  2. readSetXml(InputStream in)
  3. readSetXml(InputStream in)
  4. readSetXml(InputStream in)
  5. InputStreamToDocument(InputStream istr)
  6. getDocument(InputStream is)
  7. getPullParser(InputStream in, String encoding)
  8. newPullParser(InputStream input)
  9. obtainEncodingStringFromInputStream(InputStream bis)