Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//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;
        try {
            db = dbf.newDocumentBuilder();
        } catch (javax.xml.parsers.ParserConfigurationException e) {
            throw new RuntimeException("Parser misconfiguration");
        }

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