So I have elements that look like this
# note the space
This XPath 1.0 expression,
//li[contains(concat(' ', normalize-space(@class), ' '),
' attribute ')]
will select all li
elements with class
attributes that contain the attribute
substring, regardless of whether it has leading or trailing spaces.
If you only want to match attribute
with possible leading and trailing spaces only (no other string values), just use normalize-space()
:
//li[normalize-space(@class) = 'attribute']