Java tutorial
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.InputStream; import java.net.URL; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.*; public class Main { public static Document getDomDocument(File xmlFile) throws Exception { InputStream in = new URL("file:///" + xmlFile.getAbsolutePath()).openStream(); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbFactory.newDocumentBuilder(); Document xmlDoc = docBuilder.parse(in); in.close(); return xmlDoc; } }