【问题标题】:Fix XML undeclared prefix namespace error修复 XML 未声明前缀命名空间错误
【发布时间】:2014-05-13 17:42:47
【问题描述】:

以下 XML 和说明来自 Google 在 https://developers.google.com/google-apps/spreadsheets/ 上发布的示例。我正在尝试使用确切的示例,但显然 XML 由于命名空间而格式错误。我试图纠正,但我对此太陌生了。如果有人可以建议如何纠正,我将不胜感激。

To update the contents of an existing row, first retrieve the row to update, modify it as desired, and then send a PUT request, with the updated row in the message body, to the row's edit URL.

Be sure that the id value in the entry you PUT exactly matches the id of the existing entry. The edit URL is highlighted in the following row entry:



<entry gd:etag='"S0wCTlpIIip7ImA0X0QI"'>
      <id>https://spreadsheets.google.com/feeds/list/key/worksheetId/private/full/rowId</id>
      <updated>2006-11-17T18:23:45.173Z</updated>
      <category scheme="http://schemas.google.com/spreadsheets/2006"
        term="http://schemas.google.com/spreadsheets/2006#list"/>
      <title type="text">Bingley</title>
      <content type="text">Hours: 10, Items: 2, IPM: 0.0033</content>
      <link rel="self" type="application/atom+xml"
        href="https://spreadsheets.google.com/feeds/list/key/worksheetId/private/full/rowId"/>
      <link rel="edit" type="application/atom+xml"
        href="https://spreadsheets.google.com/feeds/list/key/worksheetId/private/full/rowId/version"/>
      <gsx:name>Bingley</gsx:name>
      <gsx:hours>20</gsx:hours>
      <gsx:items>4</gsx:items>
      <gsx:ipm>0.0033</gsx:ipm>
    </entry>

错误是:

'gd' is an undeclared prefix.

【问题讨论】:

    标签: php xml namespaces


    【解决方案1】:

    这看起来像是一个更大的 XML 文档的一部分。更具体地说,它看起来像是来自带有附加名称空间的 Atom 提要的 Atom 条目。我假设字符串函数(可能是正则表达式)用于从文档字符串中提取条目。这破坏了 XML。不仅缺少其他命名空间的命名空间前缀定义,还缺少默认命名空间。通常所有的定义都是在 atom 提要的文档元素上完成的。

    【讨论】:

    • 感谢您的回复。我根本没有提取它,它只是谷歌在我上面粘贴的链接上显示的内容。不知何故,我应该使用它来将更新的数据发送回 API。你可能是对的,它是一个更大结构的一部分,但我不知道那会是什么。
    • 经过一番研究,我刚刚从文档的“检索基于列表的提要”部分复制了标题,并且它起作用了。谢谢你的线索。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-01-27
    • 1970-01-01
    • 2019-02-19
    • 2014-12-31
    • 1970-01-01
    • 1970-01-01
    • 2019-09-26
    相关资源
    最近更新 更多