Reputation: 501
<Document >
<Documentdate>"2019"</Documentdate>
<Order size="2">
<Title>abc</Title>
<Price>10</Price>
<date>"2019"</date>
</Order>
<Order size="2">
<Title>xyz</Title>
<Price>20</Price>
<date>"2018"</date>
</Order>
<Order size="4">
<Title>Harry</Title>
<Price>10</Price>
<date>"2017"</date>
</Order>
</Document>
I need to use Xpath and read the orders that the date element is equal to Documentdate. I write in this way but it is not correct
/Document/Order[date = '../Documentdate']
Can anyone help me how can I set condition based on another element?
thank
Upvotes: 0
Views: 72
Reputation: 34596
You're comparing it to the string '../Documentdate'
, not the node value. Use:
/Document/Order[date = ../Documentdate]
Upvotes: 2