首页 > 解决方案 > 来自 QGIS 元数据文件的 Google ImportXML

问题描述

我正在尝试使用 Google 表格 importxml 捕获 qmd 文件(即 xml 标记)的元素。基于How to use importXML function with a file from Google Drive?我想我已经正确导入了文件,但似乎无法捕获任何标签。

这就是我正在尝试的 -

=importXML("https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download","\\identifier")

这是 qmd/xml 文件的样子

<!DOCTYPE qgis PUBLIC 'http://mrcc.com/qgis.dtd' 'SYSTEM'>
<qgis version="3.9.0-Master">
  <identifier>Z:/My Drive/Mangoesmapping/Spatial Projects/2019/DSC/132_Ongoing_Asset_Updates/Working/Sewerage_Updates/Sewerage_Manholes_InspectionShafts.TAB</identifier>
  <parentidentifier>Sewerage Manhole Infrastructure</parentidentifier>
  <language>AUS</language>
  <type>dataset</type>
  <title>Sewerage Manholes within Douglas Shire Council</title>
  <abstract>Sewerage Manholes within Douglas Shire Council. Most data has been updated based on field work, review of existing AsCon files and discussion with council staff responsible for the assets in 2018/2019. In Port Douglas most of the infrastructure has been surveyed in. </abstract>
  <keywords vocabulary="gmd:topicCategory">
    <keyword>Infrastructure</keyword>
    <keyword>Sewerage</keyword>

如果我使用

=importXML("https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download","*")

我明白了 在此处输入图像描述

但我真的很想通过将每个标签的 importxml 放在我需要它的单元格中来获得我想要的元素。

标签: qgisgoogle-sheets-importxml

解决方案


  • 你想###<identifier>###</identifier>https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download

我可以像上面那样理解。如果我的理解是正确的,这个答案怎么样?

问题:

=importXML("https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download","\\identifier")在您的问题中,用作\\identifierxpath的公式。从您要检索值的数据中,您似乎正在尝试检索###.<identifier>###</identifier>

在这种情况下,为了Selects nodes in the document from the current node that match the selection no matter where they are//需要使用 ,而不是\\。这可以在此处的文档中看到

修改公式:

所以=importXML("https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download","\\identifier")可以修改如下。

=importXML("https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download","//identifier")

与其他 xpath 一样,根据您问题中的数据,您也可以使用 xpath of/qgis/identifier而不是//identifier. 所以你也可以使用下面的公式。

=importXML("https://drive.google.com/uc?id=1AI2C8hQnSOuuoyJXizYBszGmpMXW8xxT&export=download","/qgis/identifier")

参考:


推荐阅读