【问题标题】:Convert xml to atom feed将 xml 转换为 atom 提要
【发布时间】:2012-02-20 21:32:40
【问题描述】:

我想将下面的 xml 转换为 atom 提要:

<item>
    <offerStartDate>2012-15-02</offerStartDate>
    <offerEndDate>2012-19-02</offerEndDate>
    <title>Item Title</title> 
    <rrp>14.99</rrp>
    <offerPrice>9.99</offerPrice>
</item>

我能够获得标准的原子元素,如 &lt;title&gt;,但似乎无法扩展提要以包含外部元素,如 &lt;rrp&gt;&lt;offerPrice&gt; 等。

这是我的尝试:

<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Item sales feed</title>
  <entry>
    <title>Item Title</title> 
    <rrp>14.99</rrp>
    <offerPrice>9.99</offerPrice>
    <image>http://mydomain.com/test/sampleImg.jpg</image>
  </entry>
</feed>

请有人帮忙!

【问题讨论】:

    标签: php xml feed atom-feed


    【解决方案1】:

    如果您想声明未在 Atom 规范中定义的元素,您需要创建自己的命名空间来定义这些元素。

    查看那里的说明:http://validator.w3.org/feed/docs/howto/declare_namespaces.html

    【讨论】:

    • 感谢您的回复,但不高兴......我似乎无法理解它。
    • 我不知道其他方法。除非您定义节点,否则提要永远不会验证。
    • 你对定义节点是正确的。我只是不知道如何...我是新的提要。示例代码将有很大帮助。谢谢
    • 链接似乎是关于 RSS,而不是 Atom..(?)
    猜你喜欢
    • 2013-12-28
    • 1970-01-01
    • 2012-06-05
    • 1970-01-01
    • 1970-01-01
    • 2011-06-29
    • 1970-01-01
    • 1970-01-01
    • 2021-11-06
    相关资源
    最近更新 更多