Java tutorial
//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(); return xml; } }