Java XML Parse File parseXmlFile(File file, boolean validating)

Here you can find the source of parseXmlFile(File file, boolean validating)

Description

parse Xml File

License

Open Source License

Declaration

public static Document parseXmlFile(File file, boolean validating) throws Exception 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  Copyright (c) 2012 Google, Inc./*from   ww w  .  j av a 2  s.  c  o  m*/
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 *  
 *  Contributors:
 *  Google, Inc. - initial API and implementation
 *******************************************************************************/

import java.io.File;

import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

public class Main {
    public static Document parseXmlFile(File file, boolean validating) throws Exception {
        // Create a builder factory
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setValidating(validating);

        // Create the builder and parse the file
        Document doc = factory.newDocumentBuilder().parse(file);
        return doc;
    }
}

Related

  1. parseXml(String filePath)
  2. parseXml(String filePath)
  3. parseXml(String value, boolean isFile)
  4. parseXMLFile(File f)
  5. parseXmlFile(File file)
  6. parseXMLFile(final File xmlFile)
  7. parseXmlFile(String filename, boolean validating)
  8. parseXmlFile(String in)
  9. parseXmlFile(String xml)