Java 使用cast-to元素的GWT XML解析器存在问题

Java 使用cast-to元素的GWT XML解析器存在问题,java,xml,gwt,xml-parsing,Java,Xml,Gwt,Xml Parsing,我正在使用GWT XML解析器解析我的应用程序上的XML文件。我举这个例子: 但是我在课堂上遇到了一个错误。以下是堆栈跟踪: ERROR: Failed to create an instance of 'xds.metadata.editor.client.editor.DocumentModelEditorView' via deferred binding java.lang.ClassCastException: com.google.gwt.xml.client.impl.Eleme

我正在使用GWT XML解析器解析我的应用程序上的XML文件。我举这个例子:

但是我在课堂上遇到了一个错误。以下是堆栈跟踪:

ERROR: Failed to create an instance of 'xds.metadata.editor.client.editor.DocumentModelEditorView' via deferred binding 
java.lang.ClassCastException: com.google.gwt.xml.client.impl.ElementImpl cannot be cast to com.google.gwt.user.client.Element
以下是我的资料来源:

Document dom= XMLParser.parse(PreParse.getInstance()
                .doPreParse(AppResources.INSTANCE.codes().getText()));

List<CodedTerm> classCodes=new ArrayList<CodedTerm>();

NodeList nodes= dom.getElementsByTagName("CodeType");

if (predefinedCodes.equals(PredefinedCodes.CLASS_CODES)){
    if (classCodes.size()==0) {
        int index = 0;
        // it is during the next line I get my error
        while (!((Element) nodes.item(index)).getAttribute("name").equals("classCode")) {
            index++;
        }
        // ....
    }
}
documentdom=XMLParser.parse(PreParse.getInstance())
.doPreParse(AppResources.INSTANCE.codes().getText());
列表类代码=新的ArrayList();
NodeList nodes=dom.getElementsByTagName(“代码类型”);
if(预定义代码.equals(预定义代码.CLASS_代码)){
if(classCodes.size()==0){
int指数=0;
//是在下一行中我得到了我的错误
while(!((元素)nodes.item(index)).getAttribute(“name”).equals(“classCode”)){
索引++;
}
// ....
}
}
有人能解释一下为什么我得到了这个classCastException,而他们在gwt项目示例代码中做了完全相同的事情吗


谢谢。

解决了这个问题。我导入了错误的元素类

小心导入com.google.gwt.xml.client.Element而不是其他东西