XPath testing that string ends with substring?

前端 未结 5 512
一整个雨季
一整个雨季 2021-01-17 17:06

Given that the HTML contains:

  
<
5条回答
  •  再見小時候
    2021-01-17 17:16

    You could use the below xpath which will work with Xpath 1.0

    //div[string-length(substring-before(@tagname, 'Destination')) >= 0 and string-length(substring-after(@tagname, 'Destination')) = 0 and contains(@tagname, 'Destination')]

    Basically it checks if there is any string ( or no strings ) before the first occurrence of Destination but there should not be any text after the Destination

    Test input :

    
    
    

    Test output:

提交回复
热议问题