RSS - 版本 1.0 標籤和語法



以下是 RSS 1.0 文件的結構

<?xml version="1.0"?>
<rdf:RDF>

   <channel>
      <title>...</title>
      <link>...</link>
      <description>...</description>
      
      <image />
      <items>...</items>
      <textInput />
   
   <image>
      <title>...</title>
      <url>...</url>
      <link>...</link>
   </image>
   
   <item>
      <title>...</title>
      <link>...</link>
      <description>...</description>
   </item>
   
   ......More item tags.....
   <textInput>
      <title>...</title>
      <description>...</description>
      <name>...</name>
      <link>...</link>
   </textInput>

</rdf:RDF>

以下是與 RSS 1.0 相關的所有可選和必填標籤的詳細資訊。檢視給出的示例以準備您網站的 RSS v1.0 Feed。

注意:所有標籤都區分大小寫,應謹慎使用。

XML 版本識別符號

作為 XML 應用程式,RSS 文件不需要以 XML 宣告開頭。它應該以 XML 版本識別符號標籤開頭。

語法

  • <?xml version="1.0"?> 或
  • <?xml version="1.0" encoding="[此處編碼程式碼]"?>

以下是 RSS v1.0 支援的編碼列表。

必需

始終且準確。可選編碼屬性(預設值為 UTF-8)。

rdf:RDF 標籤

每個符合 RSS 1.0 的文件的最外層是 RDF 元素。開啟的 RDF 標籤將 rdf: 名稱空間字首與 RDF 語法模式關聯,並將 RSS 1.0 模式建立為文件的預設名稱空間。

語法

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">

必需

始終且準確。

開始 Channel 標籤

channel 元素包含描述頻道本身的元資料,包括標題、簡短描述和指向所描述資源的 URL 連結(例如,頻道提供商的主頁)。

channel 元素的 rdf:about 屬性的 {resource} URL 必須相對於 RSS 文件中的任何其他 rdf:about 屬性唯一,並且是標識頻道的 URI。最常見的是,這要麼是正在描述的主頁的 URL,要麼是可以在其中找到 RSS 檔案的 URL。

語法

<channel rdf:about="{resource}">

必需

必需。每個 RSS 檔案最多 1 個。

頻道標題

資源的識別字符串。在專案中使用時,這是專案連結的名稱。在影像中使用時,這是影像的替代文字。在頻道中使用時,這是頻道的標題。在 textinput 中使用時,這是 textinput 的標題。

語法

<title>TutorialsPoint</title>

必需

必需。

最大長度

1-40 個字元。

頻道連結(URL)

頻道標題的 HTML 呈現將連結到的 URL,通常是父站點的首頁或新聞頁面

語法

<link>https://tutorialspoint.tw</link>

必需

必需。

最大長度

1-500 個字元。

頻道描述

頻道將具有如下所述的 description 標籤

語法

<description>Your source for tutorials, references and manuals!</description>

必需

必需。

最大長度

1-500 個字元。

頻道 Image 標籤

在可選 image 元素和此特定 RSS 頻道之間建立 RDF 關聯。rdf:resource 的 {image_uri} 必須與 image 元素的 rdf:about {image_uri} 相同。

語法

<image rdf:resource="{image_uri}" />

必需

僅當文件正文中存在 image 元素時才需要

頻道 Item 標籤

RDF 目錄,將文件的專案與此特定 RSS 頻道關聯。每個專案的 rdf:resource {item_uri} 必須與關聯的 item 元素的 rdf:about {item_uri} 相同。

RDF Seq(序列)用於包含所有專案,而不是 RDF Bag 以表示渲染和重建的專案順序。

請注意,出現在文件中但不是頻道級別專案序列成員的專案可能會被 RDF 解析器丟棄。

語法

<items><rdf:Seq><rdf:li resource="{item_uri}" /> ... </rdf:Seq></items>

必需

必需。

頻道 textInput 標籤

在可選 textinput 元素和此特定 RSS 頻道之間建立 RDF 關聯。{textinput_uri} rdf:resource 必須與 textinput 元素的 rdf:about {textinput_uri} 相同。

語法

<textinput rdf:resource="{textinput_uri}" />

必需

僅當 texinput 元素存在時才需要。

結束 Channel 標籤

Channel 開始標籤需要一個結束 Channel 標籤。

語法

</channel>

必需

必需。

Image 開始標籤

要與頻道的 HTML 呈現相關聯的影像。此影像應為大多數 Web 瀏覽器支援的格式。雖然較後的 0.91 規範允許寬度為 1-144 和高度為 1-400,但慣例(以及 0.9 規範)規定為 88x31。

語法

<image rdf:about="{image_uri}">.

必需

可選;如果存在,也必須存在於 channel 元素中。

image title 標籤

作為 HTML 呈現時與頻道的 image 標籤關聯的替代文字(“alt”屬性)。

語法

<title>{image_alt_text}</title>

必需

如果 image 元素存在,則為必需。

最大長度

1-40 個字元。

image url 標籤

作為 HTML 呈現時在頻道的 image 標籤的“src”屬性中使用的影像的 URL。

語法

<url>{image_url}</url>

必需

如果 image 元素存在,則為必需。

最大長度

1-500 個字元。

image link 標籤

頻道影像的 HTML 呈現將連結到的 URL。這與頻道的標題連結一樣,通常是父站點的首頁或新聞頁面。

語法

<link>{image_link}</link>

必需

如果 image 元素存在,則為必需。

最大長度

1-500 個字元。

image 結束標籤

image 標籤的結束標籤。

語法

</image>

必需

必需;如果 image 標籤存在。

Item 開始標籤

雖然通常是新聞標題,但使用 RSS 1.0 的模組化可擴充套件性,這幾乎可以是任何東西:討論帖子、工作列表、軟體補丁——任何具有 URI 的物件。每個 RSS 文件至少可能包含一個專案。雖然 RSS 1.0 沒有強制執行上限,但為了與 RSS 0.9 和 0.91 向後相容,建議最多包含 15 個專案。

{item_uri} 必須相對於 RSS 文件中的任何其他 rdf:about 屬性唯一,並且是標識專案的 URI。如果可能,{item_uri} 應與 <link> 子元素的 <item> 元素的值相同。

建議每個 Feed 的專案數量為 1-15。

語法

<item rdf:about="{item_uri}">

必需

必需 1 個或更多。

Item Title 標籤

專案的標題。

語法

<title>{item_title}</title>

必需

必需;每個 item 標籤。

最大長度

1-100 個字元。

Item Link 標籤

專案的 URL。

語法

<link>{item_link}</link>

必需

必需;每個 item 標籤。

最大長度

1-500 個字元。

Item Description 標籤

專案的簡短描述/摘要。

語法

<description>{item_description}</description>

必需

可選;帶 item 標籤。

最大長度

1-500 個字元。

Item 結束標籤

item 標籤的結束標籤。

語法

</item>

必需

必需;每個 item 標籤。

開始 Text Input 標籤

用於允許使用者向釋出者站點提交查詢的輸入欄位。此元素應具有標題、連結(到 cgi 或其他處理器)、包含一些說明的描述和名稱,用作 HTML 標籤 <input type=text name="[name]"> 中的名稱

語法

<textinput rdf:about="{textinput_uri}">

必需

可選;如果存在,也必須存在於 channel 元素中。

Textinput Title 標籤

textinput 欄位的描述性標題。例如:“訂閱”或“搜尋!”。

語法

<title>{textinput_title}</title>

必需

如果 textinput 存在,則為必需。

最大長度

1-40 個字元。

Textinput Description 標籤

textinput 欄位用途的簡要說明。例如:“訂閱我們的時事通訊以獲取……”或“搜尋我們網站的檔案……”。

語法

<description>{textinput_description}</description>

必需

如果 textinput 存在,則為必需。

最大長度

1-100 個字元。

Textinput Name 標籤

文字輸入欄位的(變數)名稱。

語法

<name>{textinput_varname}</name>

必需

如果 textinput 存在,則為必需。

最大長度

1-500 個字元。

Textinput Link 標籤

將 textinput 提交定向到的 URL(使用 GET)。

語法

<link>{textinput_action_url}</link>

必需

如果 textinput 存在,則為必需。

最大長度

1-500 個字元。

Textinput 結束標籤

textInput 的結束標籤。

語法

</textInput>

必需

必需帶 textinput。

rdf:RDF 結束標籤

這是 RSS1.0 文件的結束標籤。

語法

</rdf:RDF>

必需

必需。

使用特殊字元和 HTML 實體

雖然 RSS 1.0 檔案是 XML 文件,但 RSS 0.91 透過支援完整的一套 HTML 實體擴充套件了 XML。如果您想在 <url> 或 <link> 標籤中使用特殊字元(如與號 (&)),則必須將相應的十進位制或 HTML 實體替換為這些字元。

在我們的 HTML 教程中檢視完整的一套 HTML 實體

RSS 版本 1.0 示例 Feed

以下是示例 Feed 檔案,它顯示瞭如何使用版本 1.0 編寫 RSS Feed。

<?xml version="1.0"?>

<rdf:RDF 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns="http://purl.org/rss/1.0/">
   
   <channel rdf:about="https://tutorialspoint.tw">
      <title>TutorialsPoint</title>
      <link>https://tutorialspoint.tw/rss</link>
   
      <description>
         Online Tutorials and Reference Manuals
      </description>
   
      <image rdf:resource= "https://tutorialspoint.tw/images/tp-logo.gif" />
   
      <items>
         <rdf:Seq>
         <rdf:li resource="https://tutorialspoint.tw/rss/index.htm" />
         <rdf:li resource="https://tutorialspoint.tw/php/index.htm" />
         </rdf:Seq>
      </items>
   
      <textinput rdf:resource= "https://tutorialspoint.tw/tp-contact.php" />
   
   </channel>
   
   <image rdf:about="https://tutorialspoint.tw/images/tp-logo.gif">
      <title>TutorialsPoint Logo</title>
      <link>https://tutorialspoint.tw</link>
      <url>https://tutorialspoint.tw/images/tp-logo.gif</url>
   </image>
   
   <item rdf:about="https://tutorialspoint.tw/rss/index.htm">
      <title>A simple RSS tutorial</title>
      <link>https://tutorialspoint.tw/rss/index.htm</link>
   
      <description>
         Learn RSS in simple and easy steps.
      </description>
   
   </item>
   
   <item rdf:about="https://tutorialspoint.tw/php/index.htm">
      <title>A complete guide for PHP Programmers</title>
      <link>https://tutorialspoint.tw/php/index.htm</link>
   
      <description>
         A free online guide for PHP. Learn PHP in very easy steps.
      </description>
   
   </item>
   
   <textinput rdf:about="https://tutorialspoint.tw/tp-contact.php">
      <title>Contact TutorialsPoint</title>
   
      <description>
         Contact TutorialsPoint for more detail
      </description>
   
      <name>s</name>
   
      <link>
         https://tutorialspoint.tw/cgi-bin/tp-contact.cgi
      </link>
   
   </textinput>
</rdf:RDF>

RSS 1.0 副檔名

RSS 1.0 文件不需要特定的副檔名。建議使用 .rdf 或 .xml,前者更佳。

RSS 1.0 模組

RSS 1.0 模組在單獨的文件中維護,可在 RSS 1.0 模組 線上獲取。

rss-feed-formats.htm
廣告

© . All rights reserved.