Reputation: 3
Suppose I have the XML file
<?xml version="1.0" ?>
<Tasks>
<Task>
<id>1234</id>
<name>abc</name>
</Task>
<Task>
<id>5678</id>
<name>xyz</name>
</Task>
<Tasks>
How can I extract the value of id
using the value of name
? For example I know the name is abc
. How can i extract the value 1234
from the above file?
Upvotes: 1
Views: 64
Reputation: 7880
Use the following XPath query to get the id
element for a Task
with the name
of abc
:
/Tasks/Task[name='abc']/id
Example of this is here.
Upvotes: 1