Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with build path

I'm trying to use the setTextContent method in the piece of code below and I'm getting this compilation error in Eclipse:

The method setTextContent(String) is undefined for the type Element

But once I changed the order of buildpath, I was able to compile this code without errors.

import org.w3c.dom.Element;
import org.w3c.dom.Node;

Element element = (Element) list.item(i);
Node node = list.item(i);
if ("Date ".equals(node.getNodeName())) {
    element.setTextContent("");
}

Is there any alternate way rather than changing the build path?

like image 954
Vamshi Avatar asked Dec 03 '13 15:12

Vamshi


1 Answers

getTextContent/setTextContent method were introduced with DOM Level 3 - which was added in Java 5. Which version of jre are you using and also check that you don't have two jre's installed.

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.

Go to Order and Export Tab, select the jdk library and click on Buton TOP to move it all the way up, so that have to be the first libraries to use.

Move the xml-apis-1.0.b2.jar (or the version you have) all the way to the bottom, past the built in JVM libraries.

like image 76
Rahul Gupta Avatar answered Nov 02 '22 06:11

Rahul Gupta