Java XML Document from File loadRootElement(DocumentBuilder documentBuilder, File file)

Here you can find the source of loadRootElement(DocumentBuilder documentBuilder, File file)

Description

load Root Element

License

Open Source License

Declaration

public static Element loadRootElement(DocumentBuilder documentBuilder, File file) throws Exception 

Method Source Code


//package com.java2s;
/*//www . j  a v a 2s.  c o m
 * Copyright (c) 2014 Eike Stepper (Berlin, Germany) and others.
 * 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:
 *    Eike Stepper - initial API and implementation
 */

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;

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

public class Main {
    public static Element loadRootElement(DocumentBuilder documentBuilder, File file) throws Exception {
        Document document = loadDocument(documentBuilder, file);
        return document.getDocumentElement();
    }

    public static Document loadDocument(DocumentBuilder documentBuilder, File file)
            throws SAXException, IOException {
        return documentBuilder.parse(file);
    }
}

Related

  1. load(String file)
  2. load(String sFileName)
  3. loadDocument(File documentFile)
  4. loadDocument(File file)
  5. loadDocument(String filePath)
  6. loadXML(String filename)
  7. loadXml(String fileName)
  8. loadXml(String filePath)
  9. loadXml(String fn)