I have the following: \[code\]public static void main(String args[]) { // upload config' data for program - param' are path and Xml's Root node/ where to get data from confLoader conf = new confLoader("conf.xml", "config"); System.out.println(conf.getDbElement("dataSource") ); System.out.println(conf.getDbElement("dataSource") ); System.out.println(conf.getDbElement("dataSource") ); // Fails ...\[/code\]\[code\]public class confLoader{ DocumentBuilderFactory docBuilderFactory; DocumentBuilder docBuilder; Document doc; NodeList nList; public confLoader(String path, String XmlRoot){ try { docBuilderFactory = DocumentBuilderFactory.newInstance(); docBuilder = docBuilderFactory.newDocumentBuilder(); doc = docBuilder.parse(new File(path)); // normalize text representation doc.getDocumentElement().normalize(); nList = doc.getElementsByTagName(XmlRoot); } catch (Exception e) { e.printStackTrace(); } }public String getDbElement(String element) { Node nNode = nList.item(0); // 1st item/node - sql try { if (nNode.getNodeType() == Node.ELEMENT_NODE) { ///// Line 36 - Problematic Element eElement = (Element) nNode; return (((Node) eElement.getElementsByTagName(element).item(0).getChildNodes().item(0)).getNodeValue()); } } catch (Exception ex) { System.out.println("Error retrieving " + element + " :" + ex.getMessage());//Thread.dumpStack(); ex.printStackTrace(); } return "not available"; }}\[/code\]XML: \[code\]<?xml version="1.0" encoding="UTF-8"?><config> <!-- root element --> <sql> <user>XXX</user> <password>YYY</password> <dataSource>jdbc:mysql://localhost:ZZZ</dataSource> </sql></config>\[/code\]For given code I get:\[code\]jdbc:mysql://localhost:...java.lang.NullPointerExceptionjdbc:mysql://localhost:...Error retrieving dataSource :nullnot availableat exercise.confLoader.getDbElement(confLoader.java:36)at exercise.Exercise.main(Exercise.java:22)\[/code\]Line 36 is: "if (nNode.getNodeType() == Node.ELEMENT_NODE)"In words: the xml parsing is permitted/done twicw, and for the 3rd time I try to parse from Xml, I get the NullPointerException.