Reputation: 63
Below is my XML output:
<information>
<type>
<slot>0</slot>
<state>Online</state>
<name>JAMES</name>
</type>
<type>
<slot>3</slot>
<state>Online</state>
<name>Santa</name>
</type>
</information>
I am looking for a way to get the value of slot as 0 and 3.
XPath:
/information/type[name="JAMES" and name="Santa"]/slot
expected output:
<slot>0</slot>
<slot>3</slot>
Upvotes: 1
Views: 56
Reputation: 111541
Change the and
to an or
:
/information/type[name="JAMES" or name="Santa"]/slot
Even though you want to select 0 and 3, the logical property that you want to select is actually that the string value of the name
element is "JAMES"
or "Santa"
. It's the logical property that has to be placed in the predicate.
Upvotes: 2