XPath wildcard in attribute value

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)