Here you can find the source of getDomElement(File xmlFile)
public static Document getDomElement(File xmlFile) throws ParserConfigurationException, SAXException, IOException
//package com.java2s; import java.io.File; import java.io.FileReader; import java.io.IOException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; public class Main { public static Document getDomElement(File xmlFile) throws ParserConfigurationException, SAXException, IOException { Document document = null; DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory .newInstance();//from w w w . j a v a2s .c om DocumentBuilder documentBuilder = documentBuilderFactory .newDocumentBuilder(); InputSource inputSource = new InputSource(); inputSource.setCharacterStream(new FileReader(xmlFile)); document = documentBuilder.parse(inputSource); return document; } }