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 typeElement
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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With