Eclipse Node.getTextContent() in Java 1.6.0_20 Eclipse Node.getTextContent() in Java 1.6.0_20 xml xml

Eclipse Node.getTextContent() in Java 1.6.0_20


You need to go to Properties for the project in eclipse. Then select "Java Build Path" and tab "Order and Export". Here you can arrange the order of dependencies. Ensure that your JRE is higher up then Maven Dependencies.


Try using:

document.getElementsByTagName("name").item(0).getFirstChild().getNodeValue();

AFAIK It's "safer" way than getTextContent() in some cases.


I know that is an older post, but for anyone who reached this I had a similar problem and fixed it using the steps indicated in:

http://mergetag.com/the-method-gettextcontent-is-undefined-for-the-type-node/

Namely, org.w3c.dom.Node.getTextContent() is only available as of Java 1.5 but also note the declarations of Node. The xml-apis-1.0.b2.jar is the problematic one. Go into the project Properties > Java Build Path > Order and Export tab, and move xml-apis-1.0.b2.jar to the top.