Reputation: 131
I need to check whether values S1 or S2 exists in the below xml document using Xpath. I have tried something like below , but its not working. Can anyone help me in this.?
I just need to know if any of the value ( S1 or S2) exists.
Xpath I tried : "//Field/Array[String=S1 or String=S2]"
XML Document :
<Field name="F1">
<Array name="A1">
<String>S1</String>
<String>S2</String>
<String>S3</String>
<String>S4</String>
</Array>
</Field>
Upvotes: 2
Views: 1408
Reputation: 89325
You need to use single or double quotes to indicate a string literal, otherwise it will be read as child element name instead :
//Field/Array[String='S1' or String='S2']
As posted your XPath will check if value of a String
element equals to value of S1
or S2
element which will be evaluated to false since there is no child element named S1
or S2
.
Upvotes: 3