开发者

XPath condition returning "wrong" node

开发者 https://www.devze.com 2023-02-10 00:12 出处:网络
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?

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>开发者_StackOverflow中文版test</key>
     </entry>
</entries>


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']
0

精彩评论

暂无评论...
验证码 换一张
取 消