2010-01-06 75 views
4

我有這樣一個HTML表格中的行:XPath來獲取表

<table ..... class="cars"> 

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

</table> 

我怎麼能拿使用XPath錶行?

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

我可以使用或在那裏莫名其妙地說項奇|項目,甚至

回答

14

你可以得到這樣的行:

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

爲了獲得該項目,奇數行,你可以這樣做:

​​

是的,你可以使用or,如:

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

請參閱http://www.w3.org/TR/xpath瞭解更多詳情。