ImportXML Google 表格无助于从 XML 文档中提取

时间:2021-01-29 13:03:51

标签: google-sheets google-sheets-formula

我正在尝试使用 Google 表格中的 =importXML 函数从以下来源提取几个元素:https://www.ibm.com/homepage_sitemap.xml

=IMPORTXML("https://www.ibm.com/homepage_sitemap.xml","//url[*]/loc")

它给我一个 N/A 错误。下面的图片是我想提取的内容。另外,每个 hreflang 值都使用了 href=,但我在第一次提取时被卡住了。

enter image description here

2 个答案:

答案 0 :(得分:1)

您可以尝试使用此公式:

=IMPORTXML("https://www.ibm.com/homepage_sitemap.xml","//*[local-name() ='url']/*[local-name() ='loc']")

enter image description here

答案 1 :(得分:0)

试试:

=IMPORTDATA("https://www.ibm.com/homepage_sitemap.xml")

并获取网址:

=ARRAYFORMULA(QUERY(REGEXEXTRACT(
 IMPORTDATA("https://www.ibm.com/homepage_sitemap.xml"), 
 "(http.+/)"""), "where Col1 <> '#N/A'"))

enter image description here