3

我正在尝试使用 YQL 查询 html 数据。我想知道当节点有多个类时,如何基于类属性执行 html 节点的查询,例如:

<tr class='class1 class2'></tr>

此查询工作正常:

select * from html where url="http://soccernet.espn.go.com/scores" and
  xpath='//tr[@class="class1"]'

但是当我尝试查询时class2,我得到了空结果:

select * from html where url="http://soccernet.espn.go.com/scores" and
  xpath='//tr[@class="class2"]'

所以基本上我想知道当节点具有多个类属性时如何使用 YQL 查询 html 节点。

4

1 回答 1

5

可能有更好的方法 - 但这就是我遇到这个问题时的解决方法:

select * from html where url="http://soccernet.espn.go.com/scores" and xpath='//tr[contains(@class,"class2")]'
于 2012-11-16T07:12:33.710 回答