开发者

XPath query to match depending on combinations of child elements

I have the following Xml structure; Payment/Line which has amongst its element a IsFeePayment and a IsServiceProduct elements of type bool.

<Payment>
   <Line>
      <IsFeePayment>true</IsFeePayment>
       <ISServiceProduct>true</IsServiceProduct>    
   </Line>
 </Payment>

i want an xpath statement that returns 'true' when both of these are are they are, true. if either one is false, i want 开发者_运维知识库the xpath statement to return 'false'

THe xpath below is almost there, it returns the line when both are true.

/[local-name()='Payment']/[local-name()='Line'][*[local-name()='IsFeePayment'][text()='true'] and *[local-name()='IsServiceProduct'][text()='true']]

how do i just get a simple bool out instead of the whole element?


You can simplify the xpath to

boolean(//Payment/Line[IsFeePayment='true' and IsServiceProduct='true'])


simply adding a boolean() around the xpath expression i already had fixes the problem blush

so ...

boolean(/[local-name()='Payment']/[local-name()='Line'][*[local-name()='IsFeePayment'][text()='true'] and *[local-name()='IsServiceProduct'][text()='true']])

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜