本帖最后由 jijunwu 于 2009-12-05 11:40:08 编辑

解决方案 »

  1.   

    非常简单,你可以
    try{
       eElement.getFirstChild().getNodeValue()
    }catch (NullPointerException npe)
    {
       既然空指针了,那就直接说明里面为空,就认为取到的值为空字符串就好
    }
    不用去找什么特别的API,能解决问题就可以,尤其是做这种低版本的开发
      

  2.   


    伤心.....在  1.5里面做好了的 
    弄到1.4去 不支持 泛型  不支持  枚举 连读取XML的方法也不一样...........
    有没有 不通过 Try    catch    直接 改点 读取的方法的
      

  3.   

    eElement.getFirstChild().getNodeValue();
    这里有问题,那个eElement本来就是age了,既然ege里面没有子节点,getFirstChild当然是空,对空再getNodeValue()能取到什么
      

  4.   

    看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()就可以了
      

  5.   

    谢谢 各位了   
    不太会 看JDK文档  
    Aniao  正解