Here you can find the source of readXML(File xml)
private static Document readXML(File xml) throws ParserConfigurationException, SAXException, IOException
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Document; import org.xml.sax.SAXException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.File; import java.io.IOException; public class Main { private static Document readXML(File xml) throws ParserConfigurationException, SAXException, IOException { DocumentBuilderFactory builderFactory = DocumentBuilderFactory .newInstance();/*from w ww . j a v a2s . c om*/ builderFactory.setNamespaceAware(true); DocumentBuilder builder = builderFactory.newDocumentBuilder(); return builder.parse(xml); } }