I load some XML lines as follows:
Document doc = getDocumentBuilder().parse(new InputSource(new StringReader(xml)));
Later I will extract node from this Document:
XPath xpath = getXPathFactory().newXPath();
XPathExpression expr = xpath.compile(expressionXPATH);
NodeList nodeList = (NodeList)expr.evaluate(doc, XPathConstants.NODESET);
Node node = nodeList.item(0);
Now I want to get the local name of this node, but I get null.
node.getLocalName(); // return null
With a debugger, I saw that my node has the following type: DOCUMENT_POSITION_DISCONNECTED .
Javadoc claims to getLocalName()return a nullnode for this type.
- Why is node type DOCUMENT_POSITION_DISCONNECTED and not ELEMENT_NODE?
- How to "convert" node type?
source
share