2010-01-06 66 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了解更多详情。