IMPORTXML table 交替行

IMPORTXML table with alternating rows

我想使用 Google Sheet IMPORTXML 函数从 this Fangraphs 页面仅导入“1B”列。

我可以使用这个功能:

=importxml("http://www.fangraphs.com/statsd.aspx?playerid=9166&position=C&type=1&gds=&gde=&season=2015", "//tr[@class='rgRow']/td[10]")

导入 table 中的 EVERY OTHER 行,因为 table 被拆分为 'rgRow' 的两个 类和 'rgAltRow.' 但是,我需要导入 行。

我还想在列表中一直导入,而不是在每个新的 header 处停止。

这是怎么做到的?我宁愿 而不是 使用多个 IMPORTXML 函数来快速保持页面 运行。

假设这是一个 xpath 查询,试试这个:

=importxml("http://www.fangraphs.com/statsd.aspx?playerid=9166&position=C&type=1&gds=&gde=&season=2015", "//tr[@class='rgRow']/td[10] | //tr[@class='rgAltRow']/td[10]")

注意添加 | 字符(对于 'or')和 //tr[@class='rgAltRow']/td[10]

的第二个表达式