0

我想获取带有嵌入式段的网站的 RSS 提要,但不能。在使用脾气数据后,我发现 XML 导致了一个提要,但没有验证。我测试了返回以下内容的提要的有效性:

看起来这是一个网页,而不是提要。我寻找与此页面相关的提要,但找不到。请输入您的供稿地址以进行验证。

查看此 XML 的源代码(经过修改,截断如下),它似乎不是 HTML 页面:

<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:bt="http://example.com/2009/atom_extensions">
  <title>IDUG DB2 Tech Channel</title>
  <id>tag:example.com,2012:channel:7637</id>
  <bt:description>Desciption</bt:description>
  <subtitle>Joint DB2 Tech Talk series sponsored by IDUG with IBM</subtitle>
  <updated>2012-04-18T16:53:39Z</updated>
  <link href="http://www.example.org" rel="alternate" type="text/html"/>
  <link href="http://www.example.com/channel/7637/feed" rel="self" type="application/atom+xml"/>
  <entry>
    <id>tag:example.com,2012:communication:47115</id>
    <title>DB2 Tech Talk: Oracle Database and PL/SQL Compatibility Features of DB2 10</title>
    <updated>2012-05-31T16:30:00Z</updated>
    <summary>blah blah</summary>
    <author>
      <name>Serge Rielau</name>
    </author>
    <bt:communication id="47115"/>
    <bt:channel id="7637"/>
    <bt:status>upcoming</bt:status>
    <bt:format>audio</bt:format>
    <bt:duration>5400</bt:duration>
    <bt:start>1338481800</bt:start>
    <bt:entryTime>1338481500</bt:entryTime>
    <bt:closeTime>1338487500</bt:closeTime>
    <bt:rating>0</bt:rating>
    <link href="http://www.example.org?commid=47115" rel="alternate" type="text/html"/>
    <link href="http://www.example.com/communication/47115/tn1_1.png" rel="enclosure" type="image/png" title="thumbnail"/>
    <link href="http://www.example.com/communication/47115/slide1_001.png" rel="related" type="image/png" title="preview"/>
    <link href="http://www.example.com/communication/47115/calendar/ics" rel="related" type="text/calendar" title="calendar"/>
    <category scheme="keyword" term="DB2"/>
    <category scheme="keyword" term="Oracle"/>
    <category scheme="keyword" term="Database"/>
    <category scheme="keyword" term="PL/SQL"/>
    <category scheme="keyword" term="compatibility"/>
    <category scheme="keyword" term="SQL"/>
  </entry>
  ...
</feed>

为什么这不是有效的 RSS 提要?http://www.idug-db2.com/上的页面是否有我可以使用的 RSS 提要?

4

1 回答 1

0

RSS 是一种 XML,它具有自己定义的一组元素,必须出现这些元素才能使其有效。

RSS 是 XML 的一种方言。所有 RSS 文件都必须符合万维网联盟 (W3C) 网站上发布的 XML 1.0 规范。

就像有翼精灵和矿工矮人是类人生物一样,但它们的构造不同。你在这里也有同样的事情。它是一个有效的 XML 提要,站点能够根据需要在嵌入部分中摄取和消化。

但它不是一个有效的 RSS 提要,因为它没有所需的元素以及添加不属于 RSS 规范的其他元素。

如果您有一个可以根据需要解释 XML 提要源的解析器,或者您可以编写自己的类/方法,那么您正在查看的那个就可以了。正如示例站点所做的那样。

只是不适用于那些期望 RSS 采用规范定义的格式的读者或解析器。

于 2012-04-28T01:13:14.000 回答