How can I match on an attribute that contains a certain string?

后端 未结 10 2158
一整个雨季
一整个雨季 2020-11-22 03:14

I am having a problem selecting nodes by attribute when the attributes contains more than one word. For example:

10条回答
  •  梦如初夏
    2020-11-22 03:46

    To add onto bobince's answer... If whatever tool/library you using uses Xpath 2.0, you can also do this:

    //*[count(index-of(tokenize(@class, '\s+' ), $classname)) = 1]
    

    count() is apparently needed because index-of() returns a sequence of each index it has a match at in the string.

提交回复
热议问题