2
对于给定的元素,我想检查xsi:nil
属性是否设置为true。etree获取属性作为值而不是字符串
我当前的代码是
xsinil = dataFact.get('{http://www.w3.org/2001/XMLSchema-instance}nil', False)
但不是被True
XSINIL为字符串类型...
什么是最好的解决方案?我不认为这是非常优雅:
xsinil=dataFact.get('{http://www.w3.org/2001/XMLSchema-instance}nil', False)
if xsinil == 'true' or xsinil == '1' :
xsinil = True
-1'Element.get(属性名称,假)'将永远不会返回TRUE; –
同意,最终的答案将是'XSINIL = dataFact.get(” ......')in('true','1')' – rds
@rds:所以不接受这个答案并接受我的。 –