Java tutorial
//package com.java2s; import java.io.File; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { private static final DocumentBuilderFactory DOCUMENT_BUILDER_FACTORY = DocumentBuilderFactory.newInstance(); public static Document convertFileToDom(File xmlFile) { Document document; try { document = DOCUMENT_BUILDER_FACTORY.newDocumentBuilder().parse(xmlFile); } catch (Exception e) { throw new IllegalStateException("Incoming file is not valid xml", e); } return document; } }