Java tutorial
//package com.java2s; import java.io.File; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { public static Element getroot(String siteName) { Element root = null; try { File fXmlFile = new File(siteName); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); Document document = dBuilder.parse(fXmlFile); root = document.getDocumentElement(); } catch (Exception e) { e.printStackTrace(); } return root; } }