Java XML Parse File parse(String xmlFile)

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

Description

parse

License

Open Source License

Declaration

public static Document parse(String xmlFile) throws Exception 

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 javax.xml.parsers.ParserConfigurationException;

import java.io.File;

public class Main {
    public static Document parse(String xmlFile) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        return builder.parse(new File(xmlFile));
    }//from   w  w  w  .  j a  va  2s. c  o m

    public static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
        return newDocumentBuilderFactory().newDocumentBuilder();
    }

    public static DocumentBuilderFactory newDocumentBuilderFactory() {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        return dbf;
    }
}

Related

  1. parse(String fileName)
  2. parse(String fileName)
  3. parse(String fileName)
  4. parse(String fileName)
  5. parse(String filename)
  6. parseAIMLFile(File file)
  7. parseData(String filename)
  8. parseDoc(File xmlFile)
  9. parseFile(Class context, String name)