Java XML Document Create getDocument()

Here you can find the source of getDocument()

Description

Generate a document from an internal file

License

Open Source License

Exception

Parameter Description
IOException When the file couldn't be created
ParserConfigurationException When a document builder could't be made
SAXException When the manifest file couldn't be parsed to a Document

Return

A document

Declaration

public static Document getDocument() throws IOException, SAXException, ParserConfigurationException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2017, i8c N.V. (Integr8 Consulting; http://www.i8c.be)
 * All Rights Reserved.//w  ww . j a  v a2 s .  c o m
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 *******************************************************************************/

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

import java.io.IOException;

public class Main {
    /**
     * Generate a document from an internal file
     *
     * @return A document
     * @throws IOException When the file couldn't be created
     * @throws ParserConfigurationException When a document builder could't be made
     * @throws SAXException When the manifest file couldn't be parsed to a Document
     */
    public static Document getDocument() throws IOException, SAXException, ParserConfigurationException {
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        return dBuilder.parse(Thread.currentThread().getContextClassLoader()
                .getResourceAsStream("IntermediateXmlTest_Success2.xml"));
    }
}

Related

  1. createEmptyElement(Document doc, QName qname)
  2. createNewDocument()
  3. createNewDocument(DocumentBuilder docBuilder)
  4. createNewDocument(String namespaceURI, String qualifiedName)
  5. getDocument()
  6. getDocument()
  7. getDocument(Document document)
  8. getDocument(DOMSource source)
  9. getDocument(File f)