Xpath:测试值

时间:2013-09-06 15:23:45

标签: xpath

如果属性中有任何值“失败”,我如何构建XPath表达式测试?

例如,对于此XML,它应返回“TRUE”

<Properties>
  <Property Descriptor="100">1377349460.298</Property>
  <Property Descriptor="101">1</Property>
  <Property Descriptor="24000">fail</Property>
</Properties>
<Properties>
  <Property Descriptor="100">1377349462.298</Property>
  <Property Descriptor="101">1</Property>
  <Property Descriptor="24000">pass</Property>
</Properties>

为此,它应该返回“FALSE”

<Properties>
  <Property Descriptor="100">1377349460.298</Property>
  <Property Descriptor="101">1</Property>
  <Property Descriptor="24000">pass</Property>
</Properties>
<Properties>
  <Property Descriptor="100">1377349462.298</Property>
  <Property Descriptor="101">1</Property>
  <Property Descriptor="24000">pass</Property>
</Properties>

提前致谢!

1 个答案:

答案 0 :(得分:2)

文档在这里 Function: boolean boolean(object)

是的可能: -

boolean(//Property[.='fail'])

第一个xml的上述表达式将返回true,而第二个xml将返回false