Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using wildcard in Xpath with attributes

Tags:

xpath

Here is my html contents that I am trying to parse with XPath

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

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

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

but this approach is not working.What could be the correct way?

like image 830
user1107888 Avatar asked Apr 17 '13 11:04

user1107888


1 Answers

You can use "contains":

//td[contains(@class, 'text')]
like image 163
Nora Avatar answered Nov 17 '22 01:11

Nora