【问题标题】:Import XML-feed to Google Sheets将 XML 提要导入 Google 表格
【发布时间】:2018-06-26 07:30:21
【问题描述】:

我有一个看起来像这样的 XML 提要

<rss xmlns:g="http://base.google.com/ns/1.0" version="2.0">
  <channel>
    <title>Name of store</title>
    <link>Link to store</link>
    <description>Google Merchant Center product feed</description>
      <item>
        <title>Producttitle</title>
        <link> </link>
        <description> </description>
        <g:id> </g:id>
        <g:condition> </g:condition>
        <g:price> </g:price>
        <g:availability> </g:availability>
        <g:image_link> </g:image_link>
        <g:gtin> </g:gtin>
        <g:brand> </g:brand>
        <g:product_type> </g:product_type>
      </item>

我需要帮助,通过脚本以适当的方式将其输入 Google 表格。 我现在使用这个代码

SpreadsheetApp.getActiveSpreadsheet().getRange('B2').setValue('=importxml("URL2Feed";"//item//title")')

它适用于标题、链接 abd 描述,但我无法将 g:* 放入工作表中。它给了我一个#N/A

谁能帮帮我:-)

【问题讨论】:

    标签: xml google-apps-script google-sheets google-sheets-formula


    【解决方案1】:

    好的。我让导入工作。要获取导入的属性,我使用此代码

    IMPORTXML("https://URL2FEED";"//*[local-name()='id']")
    

    我将此代码输入 A2、B2、C2 等,但有些字段没有文本。这是来自商店的产品提要,然后价格出现在错误产品旁边。

    所以现在我需要一个可以正确解析这个提要的脚本:-)

    【讨论】:

      【解决方案2】:

      尝试通过没有命名空间的名称访问属性。

      看看this document

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-12-11
        • 1970-01-01
        • 2023-03-08
        • 1970-01-01
        相关资源
        最近更新 更多