开发者

XPath: contains(./text(), 'str') will look only into the first text descendent

开发者 https://www.devze.com 2023-04-06 08:26 出处:网络
I\'m trying to write an XPath query that will select an element, whose text con开发者_C百科tains given string:

I'm trying to write an XPath query that will select an element, whose text con开发者_C百科tains given string:

<div>Text1<strong>censored</strong>Text2</div>

So the following query wont match

//div[contains(./text(), 'Text2')]/strong/text()

But this one will, the text node index is explicitly stated:

//div[contains(./text()[2], 'Text2')]/strong/text()

how do I write a query that will match any text descendent?


//div[text()[contains(., 'Text2')]]/strong/text()
0

精彩评论

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