Java XML Parse File parse(File file)

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

Description

parse

License

Open Source License

Declaration

public static Document parse(File file) 

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 parse(File file) {

        Document configDoc = null;

        try {/* w  ww.jav  a  2s.  com*/

            File fXmlFile = file;
            DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
            DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
            configDoc = dBuilder.parse(fXmlFile);
            configDoc.getDocumentElement().normalize();

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

Related

  1. parse(File f, boolean validation)
  2. parse(File f, DefaultHandler dh)
  3. parse(File file)
  4. parse(File file)
  5. parse(File file)
  6. parse(File file)
  7. parse(File file)
  8. parse(File file)
  9. parse(File iFile)