Java解析XML getNodeValue()返回空

来源:互联网 发布:0基础软件开发 编辑:程序博客网 时间:2024/06/05 03:20

最近在写解析XML的程序,可能是更新jar包的原因,原有程序居然报错了,程序代码:

org.w3c.dom.NodeList rsdes = resDoc.getElementsByTagName("resultdescription");
if(rsdes!=null&&rsdes.getLength()>0){
throw new RuntimeException(rsdes.item(0).getTextContent());
}
throw new RuntimeException("提交失败!");

org.w3c.dom.Node 居然没有了这个方法,使用rsdes.item(0).getNodeValue()返回的是null,

把红色的哪一行代码改为:

throw new RuntimeException(rsdes.item(0).getFirstChild().getNodeValue());


0 0
原创粉丝点击