Seth,

The first child of the result of  getDocumentElement is not guaranteed
to be an Element.    The ClassCastException is telling you that you are
trying to cast a Text Node into an ElementNode -- which doesn't work.

Ted
----- Original Message ----- 
From: "Seth Ladd" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, January 02, 2000 6:10 PM
Subject: Exception: DeferredTextImpl


> Hello,
> 
> I'm sorry if this has been mentioned before on the mailing list.  I
> tried to look through the archives, but I didn't see this.
> 
> I am trying to use the latest Xerces-J parser, but I get an exception
> when I try to access the first child from the root.
> 
> I get a java.lang.ClassCastException:
> org.apache.xerces.dom.DeferredTextImpl exception thrown when I try to
> execute the line:
> 
> child = (Element)trueroot.getFirstChild();
> 
> I'm not sure what to do, since I'm not sure what the exception message
> is telling me.  I am using the IBM JDK 1.1.8 JDK on Linux 2.2.13.  The
> Xerces-J parser is the latest from CVS.
> 
> Here is a code snipet:
> 
> DOMParser parser = new DOMParser();
> parser.parse(filename);
> Document doc = parser.getDocument();
> Element trueroot = (Element)doc.getDocumentElement();
> Element child = (Element)trueroot.getFirstChild();
> 
> Any hints or ideas would be greatly appreciated.
> 
> Thanks very much,
> Seth
> 

Reply via email to