Google 从 QGIS 元数据文件导入 XML

2024-02-05

我正在尝试使用 Google Sheets importxml 捕获 qmd 文件的元素(即 xml 标记)。基于如何对 Google Drive 中的文件使用 importXML 函数? https://stackoverflow.com/questions/45988417/how-to-use-importxml-function-with-a-file-from-google-drive?rq=1我认为我已正确导入文件,但似乎无法捕获任何标签。

这就是我正在尝试的-

=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>

If I use

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

I get enter image description here

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


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

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

Issue:

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

在这种情况下,为了Selects nodes in the document from the current node that match the selection no matter where they are, //需要使用而不是\\。这可以在文档中看到here https://www.w3schools.com/xml/xpath_syntax.asp.

修改后的公式:

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

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

与其他 xpath 一样,根据您问题中的数据,您还可以使用以下 xpath/qgis/identifier代替//identifier。所以你也可以使用下面的公式。

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

参考:

  • 导入XML https://support.google.com/docs/answer/3093342
  • XPath 教程 https://www.w3schools.com/xml/xpath_intro.asp
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Google 从 QGIS 元数据文件导入 XML 的相关文章

随机推荐