首页 > 解决方案 > 谷歌表格 ImportXml() 从表中提取数据

问题描述

我正在尝试使用 IMPORTXML 函数从 URL 检索单个单元格数据,但不知道如何扩展查询。以下查询检索所有行。

=IMPORTXML("https://www.bullion-rates.com/gold.htm", "//td[@class='rate']")

    1,276.84    ChartsHistory
    1,146.68    ChartsHistory
    1,011.26    ChartsHistory
    82,979      ChartsHistory

但我只需要第 4 行和第 1 列 (82,979) 中的数据。如何使用 importxml 进行查询。

标签: xmlxpathgoogle-sheets

解决方案


这个之前已经回答过了。尝试:

=index(IMPORTXML("https://www.bullion-rates.com/gold.htm", "//td[@class='rate']"),4,1)

推荐阅读