Java tutorial
//package com.java2s; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; public class Main { /** * Returns a new DOM document for the given URI. * * @param uri * URI to parse into the document. * @return Returns a new DOM document for the given URI. */ public static Document loadDocument(String uri) { try { DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder(); return docBuilder.parse(uri); } catch (Exception e) { e.printStackTrace(); } return null; } }