Java XML Parse File parseXmlFile(String xmlFile)

Here you can find the source of parseXmlFile(String xmlFile)

Description

parse Xml File

License

Apache License

Declaration

public static Document parseXmlFile(String xmlFile) throws Exception 

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;

public class Main {
    public static Document parseXmlFile(String xmlFile) throws Exception {
        //get the factory
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

        //Using factory get an instance of document builder
        DocumentBuilder db = dbf.newDocumentBuilder();

        //parse using builder to get DOM representation of the XML file
        Document dom = db.parse(xmlFile);

        return dom;
    }/* ww w .  jav a  2s  .  co  m*/
}

Related

  1. parseXMLFile(final File xmlFile)
  2. parseXmlFile(String filename, boolean validating)
  3. parseXmlFile(String in)
  4. parseXmlFile(String xml)
  5. parseXmlFile(String xmlFile)