XPath: Ends With
The ends-with() function in XPath is used to select elements whose attribute values end with a specific substring. This function is particularly useful when you match elements based on the ending portion of an attribute value.
You can use the following XPath:
This selects list items (li) within an unordered list (ul) where the class attribute ends with 'border-secondary'.
Example 1: //ul[@class='list-group']/li[ends-with(@class,'border-secondary')]
This targets list items where the id attribute ends with 'border-secondary'.
Example 2: //ul[@class='list-group']/li[ends-with(@id,'border-secondary')]
- New Item
- Sample Item 0001
- Sample Item 0002
- Sample Item 0003
- Sample Item 0004
- Sample Item 0005
- Sample Item 0006
- Sample Item 0007
- Sample Item 0008
- Sample Item 0009
- Sample Item 0010