XML如下: 
<root> <node> 
<Attribute name="aa" age="24" time="2008-11-06 12:01:07"/> 
</node> </root> 获取节点 <Attribute>中属性age的值如下: 
xml_age = pElement->getAttribute("age"); 问题是: 如果节点 <Attribute>中没有属性age时候: 
如: 
<root> <node> 
<Attribute name="aa" time="2008-11-06 12:01:07"/> 
</node> </root> 再如下获取属性age的值, 程序会出异常: 
xml_age = pElement->getAttribute("age"); 那么怎么判断节点中有没有属性age呢? 
或者..可以通过别的什么方法可以见解的判断age属性是否存在呢? 谢谢大家~~!

解决方案 »

  1.   

    if( NULL == xml_age )
    {
     //没有。
    }
      

  2.   

    xml_age = pElement->getAttribute("age"); 这句在..getAttribute("age"); 时候就出异常了....if( NULL == xml_age ) 

    //没有。 
    }这个是不能被执行的啊...
    有解决方法么..
      

  3.   

    不能执行说明 pElement 是空的吧?
      

  4.   

    谢谢..问题已经解决了..解决方法是..扑捉这个异常..try..catch...