Content

Using a template in Xpath with attributes

Here is my html content I'm trying to parse using XPath

<td class="text1">Content</td>
<td class="text2">Content</td>
<td class="text2">Content</td>

I want to select td elements using the class attribute, but as is obvious, the value for this attribute is different for each element. I tried:

//td[starts-with(@class,'text')]

but this approach does not work. What could be the right way?

+5
source share
1 answer

You can use "contains":

//td[contains(@class, 'text')]
+11
source

All Articles