[英]Xpath select element where both children contains text
How do I select an element where both of the children contains a specific text. 如何选择两个孩子都包含特定文本的元素。
Example: 例:
<div class="line">
<h1>
<a>1</a>
</h1>
<p>
<a>2</a>
</p>
</div>
<div class="line">
<h1>
<a>3</a>
</h1>
<p>
<a>4</a>
</p>
</div>
How do I make an XPath string that, search for the class line, and then select it where one of the spans contain 3 and 4 如何制作一个XPath字符串,搜索类行,然后在其中一个跨度包含3和4的位置选择它
I tried this 我试过了
//div[contains(@class, 'line')]
but I don't see how I can select it where first child contains 3
and second contains 4
. 但我看不到如何选择第一个孩子包含
3
且第二个孩子包含4
。
尝试通过两个子节点的确切字符串值选择div
节点
//div[contains(@class, 'line') and normalize-space(h1)='3' and normalize-space(p)='4']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.