获取兄弟/姐妹节点的价值 [英] Getting the value of brother/sister node
本文介绍了获取兄弟/姐妹节点的价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们在一个页面上说,我有很多这样的重复:
Let's say on a page I have alot of this repeated:
<div class="entry">
<h4>Magic:</h4>
<a>Edit</a>
<a>Delete</a>
</div>
但 nodeValue
h4
不重复。基于 h4 $ c $,如何获取
a
的 nodeValue
c>标签的 nodeValue
?获取h4内容为的h4的节点的$
的内容。
。
But the nodeValue
of h4
is not repeated. How do I get the nodeValue
of the a
based on the h4
tag's nodeValue
? Get content of the sister a
nodes of h4 where h4 content is Magic:
.
推荐答案
使用此XPath:
//div/h4[. = 'Magic:']/following-sibling::a[1]
它选择1 a c
It selects 1st following-sibling a
element of h4
with value Magic:
.
这篇关于获取兄弟/姐妹节点的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文