Java XML Document from File load(String file)

Here you can find the source of load(String file)

Description

load

License

Apache License

Declaration

public static Document load(String file) 

Method Source Code


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

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

import org.w3c.dom.Document;

import java.io.File;

public class Main {
    public static Document load(String file) {
        try {//  w ww .ja  va2s.c o  m
            Document document = null;
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setValidating(false);
            dbf.setNamespaceAware(false);
            DocumentBuilder builder = dbf.newDocumentBuilder();
            document = builder.parse(new File(file));
            document.normalize();
            return document;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

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