I think I can finally solve your problem. First, consider the following updated XML.java source code (I hope I get the formatting right):
This program works with the file.xml that I previously presented. For completeness, here it is again:
When I run this program under JDK 8u60, I observe the following output:
The first output line proves that the doc variable is not assigned the null reference.
The second output line shows the result of calling Document's toString() method on the reference stored in doc. This output shows that doc is referencing a Document node. This is proven by #document, which is the name of the node (as returned by Node's getNodeName() method -- Document extends Node). The null value that you are seeing after the : character is the node's value (as returned by Node's getNodeValue() method). The Document node has no value, which is verified by the third line -- doc.getNodeValue() = null.
The fourth line proves that the element variable is not assigned a null reference. Its name is adminappv and its value is null. Here is where confusion starts.
It would seem that Element element = (Element) doc.getElementsByTagName("adminappv").item(0); might return the 0 text between the <adminappv> and </adminappv> tags, but this is not the case. The text between these tags is stored in a #text node that's located (in the DOM tree) as a child of the adminappv element node. You conveniently access this child by calling the element node's getFirstChild() method. You could also use getChildNodes() and NodeList's item() method with a 0 argument, as in System.out.printf("element.getChildNodes().item(0) = %s%n", element.getChildNodes().item(0));, but that's more cumbersome.
The final line roughly repeats the output of the previous line. However, the corresponding code is a bit different to show you an alternative.
You might want to check out <a href="https://www.mathworks.com/matlabcentral/answers/260969-why-do-i-receive-an-empty-document-document-null-when-i-read-a-xml-file-with-xmlread">why do I receive an empty document [#document: null] when I read a xml file with xmlread?</a> for more information.