Java tutorial
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.IOException; import java.util.logging.Logger; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.xml.sax.SAXException; public class Main { private static Logger log = Logger.getLogger("XmlUtils"); public static Document parseDocument(final File xmlFile) throws ParserConfigurationException, SAXException, IOException { log.finer("Parsing document from file " + xmlFile.getName()); DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(true); DocumentBuilder builder = domFactory.newDocumentBuilder(); return builder.parse(xmlFile); } }