I have used org.w3c.dom.Node.getTextContent() metthod to get the text value, the same is working fine in Eclipse. When we run it as stanalone, it is taking :class org.apache.xerces.dom.DeferredElementImpl and failing. Please advice on how to get org.w3c.dom.Node.getTextContent() at runtime.
org.w3c.dom.Node is an interface.
org.apache.xerces.dom.DeferredElementImpl is an implementation of that interface (really, an implementation of
org.w3c.dom.Element, a subinterface of
Node). There are other implementations. If you write a program that uses
Node, then when you run it, you will actually be using one of the implementations.
It seems that
DeferredElementImpl does not implement
getTextContent() properly. Although it’s hard to be sure of that, given that you haven’t said what the actual problem was.
It seems that in Eclipse, you are using some implementation other than
DeferredElementImpl, and that implementation implements
getTextContent() properly. On my installation of Eclipse, i get a
com.sun.org.apache.xerces.internal.dom.ElementImpl if i create an element in the normal way.
com.sun.org.apache.xerces.internal.dom.ElementImpl is the standard implementation bundled in the Sun JRE. If you are getting a different implementation, it is because you have a non-standard XML parser on your classpath. That is perfectly fine, but it’s something you should be aware of. If you examine your standalone application’s classpath, you should find a parser that isn’t there when you run in Eclipse.