HTML XPath按类和文本搜索 [英] HTML XPath Searching by class and text
本文介绍了HTML XPath按类和文本搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想按类和文本查找xpath中的所有元素.我已经尝试过了,但是没有用.
I want to find all elements in xpath by class and text. I have tried this but it does not work.
//*[contains(@class, 'myclass')]//*[text() = 'qwerty']
我正在尝试查找所有具有"myclass"类且文本为"qwert"的元素(这些将是span元素)
I am trying to find all elements that have a class of 'myclass' and the text is 'qwert' (these will be span elements)
推荐答案
//span[contains(@class, 'myclass') and text() = 'qwerty']
或
//span[contains(@class, 'myclass') and normalize-space(text()) = 'qwerty']
这篇关于HTML XPath按类和文本搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文