Java XML Document from File loadXMLDocument(String path)

Here you can find the source of loadXMLDocument(String path)

Description

load XML Document

License

Open Source License

Declaration

public static Document loadXMLDocument(String path) 

Method Source Code

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

import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

public class Main {
    public static Document loadXMLDocument(String path) {
        return loadXMLDocument(new File(path));
    }//  w w w . j  av a 2  s  .  c  o  m

    public static Document loadXMLDocument(File file) {
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            Document document = builder.parse(file);
            return document;
        } catch (Exception ex) {
            return null;
        }
    }
}

Related

  1. loadRootElement(DocumentBuilder documentBuilder, File file)
  2. loadXML(String filename)
  3. loadXml(String fileName)
  4. loadXml(String filePath)
  5. loadXml(String fn)
  6. loadXmlDocumentFromFile(@Nonnull File file)
  7. loadXmlFromFile(String xmlFileName)
  8. read(InputStream input)
  9. read(InputStream xml)