Xpath或xquery并测试顺序

时间:2010-05-10 15:27:17

标签: xpath xquery

使用SoapUI(顺便说一下WS的优秀工具),我有以下xml结果:

<code>c</code>
<code>b</code>
<code>a</code>

对于上面的这个示例,我想测试代码值是否为命令asc。当然,对于这个样本,测试将失败,如例外。

使用xquery或xpath的任何解决方案(如果需要,我可以在测试中使用groovy)

提前致谢。

2 个答案:

答案 0 :(得分:1)

使用(XQuery或XPath 2.0):

not(code[. > following-sibling::code])

答案 1 :(得分:0)

另外两种方式:

empty(
  for $x at $p in code
  where ($x > code[$p + 1])
  return $x
)

deep-equal(for $x in code order by $x return $x/data(.), code/data(.))

但Dimitre的回答似乎最干净。