getNextSibling() error

somehow get an exception error while accessing the next sibling()?? anyone can help?

java.lang.ClassCastException: com.docuverse.dom.BasicText
at QConstruction.showResult(
at QConstruction.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.tomcat.facade.ServletHandler.doService(
at org.apache.tomcat.core.Handler.service(
at org.apache.tomcat.facade.ServletHandler.service(
at org.apache.tomcat.core.ContextManager.internalService(
at org.apache.tomcat.core.ContextManager.service(
at org.apache.tomcat.modules.server.Ajp13Interceptor.processConnection(
at org.apache.tomcat.util.threads.ThreadPool$
i am using w3cdom1.jar but i dont know whey it keep referencing to com.docuverse.dom.BasicText ??

TaminoResult tr = tamino.query("/Construction");
Element rootNode = (Element)tr.getElement();
out.println(“NodeName = " + rootNode.getNodeName()+rootNode.getNodeValue()+”

Element construction = (Element) rootNode.getFirstChild();
out.println(“NodeName = " + construction.getNodeName()+construction.getNodeValue()+”
construction1 = (Element)construction.getNextSibling(); // this is the problem statement

anyone can help pls?


cheers !

typo : construction1 = construction

The servlet is able to compile but unable to execute in tomcat und apache.
hmm the funny thing is if i declare a Node type


cheers !

Unfortunately the next sibling may not be an Element. The best thing to do is check the type of the next sibling before doing the cast. You may find that it is a BasicText if there is white space between the Elements. The reason you have BasicElement + BasicText is because the API uses the docuverse DOM to do its parsing. However the BasicElement class implements the DOM Element class as expected.

thanks … came to find that one out too.
As long as there is a carriage return in between
tags well there will be a text node an I will have to check for that.

well thanks alot :slight_smile:


cheers !