I have the following XPath to match attributes of the class span:
//span[@class='amount']
I want to match all elements that have the class attribute of “amount” but also may have other classes as well. I thought I could do this:
//span[@class='*amount*']
but that doesn’t work…how can I do this?
Use the following expression:
You could use
containson its own, but that would also match classes likesomeamount. Test the above expression on the following input:It will select the first four
spanelements, but not the last one.