Java XML Document from File getXmlDocument(File file)

Here you can find the source of getXmlDocument(File file)

Description

get Xml Document

License

Apache License

Declaration

private static Document getXmlDocument(File file) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

import java.io.IOException;

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

public class Main {
    private static Document getXmlDocument(File file) {
        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder;
        try {/*  w  ww  .j a va  2s.  c  om*/
            docBuilder = docBuilderFactory.newDocumentBuilder();
            Document doc = docBuilder.parse(file);
            return doc;
        } catch (ParserConfigurationException e) {
            return null;
        } catch (SAXException e) {
            return null;
        } catch (IOException e) {
            return null;
        }
    }
}

Related

  1. getDocumentFromFile(File file)
  2. getDocumentFromFile(String absolutePath)
  3. getXML(File file)
  4. getXML(File xmlFile)
  5. getXmlDocument(File file)
  6. getXmlDocument(String fileName)
  7. isXMLFile(File file)
  8. load(String file)
  9. load(String sFileName)