title: Why does getLocalName() return null?
body: <p>I'm loading some XML string like this:</p>
  
  <pre><code>Document doc = getDocumentBuilder().parse(new InputSource(new StringReader(xml)));
  </code></pre>
  
  <p>Later, I extract a node from this <code>Document</code>:</p>
  
  <pre><code>XPath xpath = getXPathFactory().newXPath();
  XPathExpression expr = xpath.compile(expressionXPATH);
  NodeList nodeList = (NodeList)expr.evaluate(doc, XPathConstants.NODESET);
  
  Node node = nodeList.item(0);
  </code></pre>
  
  <p>Now I want to get the local name of this node but I get <code>null</code>.</p>
  
  <pre><code>node.getLocalName(); // return null
  </code></pre>
  
  <p>With the debugger, I saw that my node has the following type: <a href="https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/Node.html#DOCUMENT_POSITION_DISCONNECTED" rel="noreferrer">DOCUMENT_POSITION_DISCONNECTED</a>.</p>
  
  <p><a href="https://docs.oracle.com/javase/7/docs/api/org/w3c/dom/Node.html#getLocalName()" rel="noreferrer">The Javadoc</a> states that <code>getLocalName()</code> returns <code>null</code> for this type of node.</p>
  
  <ul>
  <li>Why node is of type DOCUMENT_POSITION_DISCONNECTED and not ELEMENT_NODE?</li>
  <li>How to "convert" the type of the node?</li>
  </ul>