In the documentation for this interface it states that textnodes all return "#text" for their names instead of the actual tag name. But for what i'm doing, the tag name is necessary.

// I'm using the following imports
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;


// In the .xml input file
<country>US</country>  // This is a "text node" .getTextContent()
                       // returns "US", I need "country" and .getNodeName() 
                       // only returns "#text"

How could I access the tag name? This must be possible somehow, I don't mind a hackish solution.

Docs:

http://www.w3schools.com/dom/dom_nodetype.asp

http://www.w3.org/2003/01/dom2-javadoc/org/w3c/dom/Node.html

Thank you.

Edit
Report