Use the following expression:
//span[contains(concat(' ', @class, ' '), ' amount ')]
You could use contains
on its own, but that would also match classes like someamount
. Test the above expression on the following input:
<root>
<span class="test amount blah"/>
<span class="amount test"/>
<span class="test amount"/>
<span class="amount"/>
<span class="someamount"/>
</root>
It will select the first four span
elements, but not the last one.