Here you can find the source of getDocument(File file)
Parameter | Description |
---|---|
file | the file containing the XML to parse. |
public static Document getDocument(File file) throws Exception
//package com.java2s; /*--------------------------------------------------------------- * Copyright 2005 by the Radiological Society of North America * * This source software is released under the terms of the * RSNA Public License (http://mirc.rsna.org/rsnapubliclicense) *----------------------------------------------------------------*/ import java.io.*; import org.w3c.dom.Document; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; public class Main { /**/* w w w . j av a 2 s . c o m*/ * Parses an XML file. * @param realFilePath the path to the file containing the XML to parse. * @return the XML DOM document. */ public static Document getDocument(String realFilePath) throws Exception { File file = new File(realFilePath); DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); return db.parse(file); } /** * Parses an XML file. * @param file the file containing the XML to parse. * @return the XML DOM document. */ public static Document getDocument(File file) throws Exception { DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); return db.parse(file); } /** * Creates a new empty XML DOM document. * @return the XML DOM document. */ public static Document getDocument() throws Exception { DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder(); return db.newDocument(); } }