...

Xpath to get rows inside a table

I have an html table, for example:

<table ..... class="cars"> <tr class="item-odd"> ... </tr> <tr class="item-even"> </tr> </table> 

How can I get table rows using xpath?

 //tr[contains(@class, ???) 

Is it possible to use OR in a sense to say item-odd | item-even

+4
source share
1 answer

You can get the lines as follows:

 //table[@class='cars']/tr 

To get the odd lines, you should do the following:

 //table[@class='cars']/tr[@class='item-odd'] 

Yes, you can use or , for example:

 //table[@class='cars']/tr[@class='item-odd' or @class='item-even'] 

See http://www.w3.org/TR/xpath for details.

+14
source

All Articles