看JDK1.4的文档里 org.w3c.Element是继承Node的Node里有个方法叫 getNodeValue public String getNodeValue() throws DOMExceptionThe value of this node, depending on its type; see the table above. When it is defined to be null, setting it has no effect. 估计你eElement.getNodeValue()就可以了
try{
eElement.getFirstChild().getNodeValue()
}catch (NullPointerException npe)
{
既然空指针了,那就直接说明里面为空,就认为取到的值为空字符串就好
}
不用去找什么特别的API,能解决问题就可以,尤其是做这种低版本的开发
伤心.....在 1.5里面做好了的
弄到1.4去 不支持 泛型 不支持 枚举 连读取XML的方法也不一样...........
有没有 不通过 Try catch 直接 改点 读取的方法的
这里有问题,那个eElement本来就是age了,既然ege里面没有子节点,getFirstChild当然是空,对空再getNodeValue()能取到什么
org.w3c.Element是继承Node的Node里有个方法叫
getNodeValue
public String getNodeValue()
throws DOMExceptionThe value of this node, depending on its type; see the table above. When it is defined to be null, setting it has no effect.
估计你eElement.getNodeValue()就可以了
不太会 看JDK文档
Aniao 正解