Java XML Document Parse parseFileToDocument(File f)

Here you can find the source of parseFileToDocument(File f)

Description

Read the contents of the specified file into a DOM document

License

RPL License

Parameter

Parameter Description
f the input XML file

Exception

Parameter Description
Exception an exception

Return

the document

Declaration

public static final Document parseFileToDocument(File f) throws Exception 

Method Source Code

//package com.java2s;
/*//from w ww.  jav  a 2 s  . co  m
 * Unless explicitly acquired and licensed from Licensor under another license, the contents of
 * this file are subject to the Reciprocal Public License ("RPL") Version 1.5, or subsequent
 * versions as allowed by the RPL, and You may not copy or use this file in either source code
 * or executable form, except in compliance with the terms and conditions of the RPL
 *
 * All software distributed under the RPL is provided strictly on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND LICENSOR HEREBY DISCLAIMS ALL SUCH
 * WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, QUIET ENJOYMENT, OR NON-INFRINGEMENT. See the RPL for specific language
 * governing rights and limitations under the RPL.
 *
 * http://opensource.org/licenses/RPL-1.5
 *
 * Copyright 2012-2015 Open Justice Broker Consortium
 */

import java.io.File;

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

import org.w3c.dom.Document;

public class Main {
    /**
     * Read the contents of the specified file into a DOM document
     * @param f the input XML file
     * @return the document
     * @throws Exception
     */
    public static final Document parseFileToDocument(File f) throws Exception {
        DocumentBuilderFactory docBuilderFact = DocumentBuilderFactory.newInstance();
        docBuilderFact.setNamespaceAware(true);
        DocumentBuilder docBuilder = docBuilderFact.newDocumentBuilder();
        Document document = docBuilder.parse(f);
        return document;
    }
}

Related

  1. parseDocument(String documentString)
  2. parseDocument(String path)
  3. parseDocument(String xmlString)
  4. parseDocumentIntoStringXML(Document document)
  5. parseDocumentr(File f)
  6. parseHTMLDocument(String paramString)
  7. parseInitMap(InputStream in, DocumentBuilder builder, Map> initMap)
  8. parseMultipleWorkouts(Document doc)
  9. parseResponse(InputSource is, DocumentBuilder documentBuilder)