开发者

Xpath or xquery and test the order

Using SoapUI (great tool for WS by the way), I have the following xml result :

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

For this sample above, i would like to test the code value are order asc. Of course, 开发者_运维知识库for this sample the test will fail like excepted.

Any solution with xquery or xpath (i can use groovy inside the test if necessary)

Thanks in advance.


Use (XQuery or XPath 2.0):

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


Two other ways:

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

and

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

But Dimitre's answer seems the cleanest.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜