Java XML Document Create getDocument(InputStream xml)

Here you can find the source of getDocument(InputStream xml)

Description

get Document

License

Open Source License

Declaration

public static Document getDocument(InputStream xml) throws java.io.IOException, org.xml.sax.SAXException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;

public class Main {
    public static Document getDocument(InputStream xml) throws java.io.IOException, org.xml.sax.SAXException {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setIgnoringElementContentWhitespace(true);
        DocumentBuilder db;//  w w w  .j av a 2  s . c  om
        try {
            db = dbf.newDocumentBuilder();
        } catch (javax.xml.parsers.ParserConfigurationException e) {
            throw new RuntimeException("Parser misconfiguration");
        }

        Document doc = db.parse(xml);
        return doc;
    }
}

Related

  1. getDocument(final File file)
  2. getDocument(InputStream in)
  3. getDocument(InputStream input)
  4. getDocument(InputStream inputStream)
  5. getDocument(InputStream inputStream)
  6. getDocument(InputStream xmlInputStream)
  7. getDocument(Node node)
  8. getDocument(Node parent)
  9. getDocument(Resource resource)