' IMPORTXML' - 导入XML无法在Google表格中使用

时间:2015-03-13 17:09:51

标签: xml import google-sheets

我有一个相当简单的XML可以导入Google表格,但无论我尝试多少,它仍然无法工作。错误消息始终为:

  

错误   无法解析导入的XML内容。

我尝试过几种组合,包括:

//ViewGetItemsResponse/ItemList/Item/@date

=importxml("https://example.com/rest?WebServiceKey=blah&ViewID=1004&PageNumber=1&PageItemCount=10", "//ViewGetItemsResponse/ItemList/Item/@date")

示例XML:

<?xml version="1.0" encoding="utf-8"?>
<ViewGetItemsResponse xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Result>Success</Result>
  <PageItemCount>2</PageItemCount>
  <PageNumber>1</PageNumber>
  <PageCount>26</PageCount>
  <ItemList>
    <Item>
      <ItemID>1004</ItemID>
      <Date>2015-03-05 00:00:00</Date>
      <Frontpagearticles>Example 1</Frontpagearticles>
      <LocationUrl>Example.com</LocationUrl>
      <NowTrendingarticles />
      <TopNav />
      <Created>2015-03-13 09:02:48</Created>
      <CreatedBy>Administrator</CreatedBy>
      <Deleted />
      <DeletedBy />
      <ItemID1>1004</ItemID1>
      <ItemSourceItemID>4</ItemSourceItemID>
      <ItemSourceName>1003</ItemSourceName>
      <ItemSourceType>Agent</ItemSourceType>
      <Modified />
      <ModifiedBy />
      <Refreshed>2015-03-13 09:02:48</Refreshed>
      <RefreshedBy>Administrator</RefreshedBy>
    </Item>
    <Item>
      <ItemID>1008</ItemID>
      <Date>2015-03-03 00:00:00</Date>
      <Frontpagearticles>Example2</Frontpagearticles>
      <LocationUrl>Example2.com</LocationUrl>
      <NowTrendingarticles />
      <TopNav />
      <Created>2015-03-13 09:03:02</Created>
      <CreatedBy>Administrator</CreatedBy>
      <Deleted />
      <DeletedBy />
      <ItemID1>1008</ItemID1>
      <ItemSourceItemID>8</ItemSourceItemID>
      <ItemSourceName>1003</ItemSourceName>
      <ItemSourceType>Agent</ItemSourceType>
      <Modified />
      <ModifiedBy />
      <Refreshed>2015-03-13 09:03:02</Refreshed>
      <RefreshedBy>Administrator</RefreshedBy>
    </Item>
  </ItemList>
</ViewGetItemsResponse>

1 个答案:

答案 0 :(得分:0)

作为最后的手段,您可以使用导入数据来提取信息并在之后对其进行格式化,或者如果您共享要导入的数据的真实链接,则可能会为您提供解决问题的具体答案。