Here you can find the source of getXML(File file)
public static Document getXML(File file) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.*; public class Main { public static Document getXML(File file) throws Exception { InputStream in = new FileInputStream(file); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbFactory.newDocumentBuilder(); Document xml = docBuilder.parse(in); in.close();//from w w w . ja va 2 s. c o m return xml; } }