Jonathan Egerton
Jonathan Egerton

Reputation: 350

XPath condition returning "wrong" node

When doing something like /entries/entry/key='test', I always get the node key returned. But I want the entry node. How can I get it?

My XML looks like this:

<entries>
     <entry>
           <key>test</key>
     </entry>
</entries>

Upvotes: 4

Views: 252

Answers (1)

Matt
Matt

Reputation: 3233

You want to select the entry node and match subelement "key"'s value to the text 'test' . This should do it:

/entries/entry[key='test']

Upvotes: 5

Related Questions