Java XML Document from File readXML(String path)

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

Description

Read xml from file

License

Open Source License

Declaration

public static Document readXML(String path) 

Method Source Code


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

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

import java.io.File;

public class Main {
    /**/*from   w ww . j av a 2  s .c o m*/
     * Read xml from file
     */
    public static Document readXML(String path) {

        try {

            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            return builder.parse(new File(path));

        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

    }
}

Related

  1. readXML(File file)
  2. readXML(File file)
  3. readXML(File file)
  4. readXML(File xml)
  5. readXml(String path)
  6. readXMLFile(File file)
  7. readXMLFile(String filename)
  8. readXmlFile(String fileName)
  9. readXmlFile(String fileName)