Java XML Parse File parseFile(File file)

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

Description

parse File

License

Open Source License

Declaration

public static Document parseFile(File file)
            throws org.xml.sax.SAXException, IOException, ParserConfigurationException 

Method Source Code


//package com.java2s;
//License from project: GNU General Public License 

import java.io.File;
import java.io.IOException;

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

import org.w3c.dom.Document;

public class Main {
    public static Document parseFile(File file)
            throws org.xml.sax.SAXException, IOException, ParserConfigurationException {
        return newDocumentBuilder().parse(file);
    }/*w ww  .  ja v a 2s  .  com*/

    private static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
        // SAXParsers are not concurrency compatible, so always return a new instance to prevent thread issues 
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        return dbf.newDocumentBuilder();
    }
}

Related

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