开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜