user1786107 user1786107 - 1 year ago 210
HTML Question

HTML XPath Searching by class and text

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']

I am trying to find all elements that have a class of 'myclass' and the text is 'qwert' (these will be span elements)

Answer Source
//span[contains(@class, 'myclass') and text() = 'qwerty']


//span[contains(@class, 'myclass') and normalize-space(text()) = 'qwerty']
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download