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) throws SAXException,
            IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014 Gabriel Skantze./*ww  w. j a  v  a  2 s  .  com*/
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     Gabriel Skantze - initial API and implementation
 ******************************************************************************/

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;

import org.xml.sax.SAXException;

public class Main {
    public static Document parse(File file) throws SAXException,
            IOException {
        return getBuilder().parse(file);
    }

    public static DocumentBuilder getBuilder() {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        try {
            return dbf.newDocumentBuilder();
        } catch (ParserConfigurationException e) {
            e.printStackTrace();
        }
        return null;
    }
}

Related

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