``` Atom 简介 ```
Introduction to Atom

原始链接: https://validator.w3.org/feed/docs/atom.html

## Atom:一种网络内容聚合格式 Atom 是一种基于 XML 的格式,用于发布和编辑网络内容,特别是对于经常更新的网站(如博客)。它定义了一种标准方式,让网站向读者分发更新——被称为“订阅源”,确保不同平台之间的兼容性。 Atom 订阅源是结构化的 XML 文档,遵循 `http://www.w3.org/2005/Atom` 命名空间,并使用 RFC 3339 用于时间戳。一个订阅源包含元数据(标题、更新日期、作者)和一系列“条目”——单个文章或帖子。 订阅源中的关键元素包括 `` 用于唯一标识,``,`<updated>` 和 `<author>`。条目包括 `<id>`,`<title>`,`<updated>`,`<summary>`,并且还可以包含完整的 `<content>`。链接 (`<link>`) 至关重要,用于指定关系,例如“self”(订阅源本身)或“alternate”(HTML 版本)。 Atom 具有可扩展性,允许包含来自其他命名空间的元素,使其与现有格式(如 RSS)兼容。它通过可选元素(如 `<category>`,`<contributor>` 以及详细的内容/链接规范)提供灵活性。 </p> <div class='comment'>Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Atom 介绍 (w3.org) 10 分,susam 1小时前 | 隐藏 | 过去 | 收藏 | 3 评论 帮助 intrasight 3分钟前 | 下一个 [–] Google API 的第一代是 Atom。我很怀念 XML。回复 mplanchard 12分钟前 | 上一个 | 下一个 [–] 我为我的静态生成博客手动创建了一个 Atom feed。它是一个合理且易于使用的格式。回复 perrohunter 21分钟前 | 上一个 [–] 旧事重提?回复 考虑申请 YC 2026 夏季班!申请截止至 5 月 4 日 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请 YC | 联系方式 搜索: </div> <form method='post' action='/posts/vote' class='text-right'> <input type='hidden' name='pid' value='117029' /> <button name='vote' value='1' class='btn btn-link fa-solid fa-thumbs-up text-success'></button> <button name='vote' value='-1' class='btn btn-link fa-solid fa-thumbs-down text-error'></button> </form> </div> <div class='column col-4 col-sm-12 pt-2'> <div class='h5 mt-2 mb-2'>相关文章</div> <div> </div> </div> <div class='column col-12'> <hr/> <div class='content'> <div class='h5 mt-2 mb-2'>原文</div> <div id="main" readability="175.64239365537"> <h2>Contents</h2> <h2>What is Atom?<a id="whatIsAtom" name="whatIsAtom"/></h2> <p>Atom is the name of an XML-based Web content and metadata syndication format, and an application-level protocol for publishing and editing Web resources belonging to periodically updated websites.</p> <p>All Atom feeds must be well-formed <a href="http://www.w3.org/TR/REC-xml">XML</a> documents, and are identified with the <code>application/atom+xml</code> media type.</p> <h3>About this document<a id="aboutThisDocument" name="aboutThisDocument"> </a></h3> <p>This document focuses on <a href="rfc4287.html">The Atom Syndication Format</a> produced by the <a href="http://www.ietf.org/" title="Internet Engineering Task Force">IETF</a> <a href="http://www.ietf.org/html.charters/atompub-charter.html">AtomPub Working Group</a>. In the event that this document differs from the Internet Draft, the Internet Draft is to be considered authoritative.</p> <p>General considerations:</p> <ul> <li>All elements described in this document must be in the <a href="http://www.w3.org/2005/Atom">http://www.w3.org/2005/Atom</a> namespace.</li> <li>All timestamps in Atom must conform to <a href="http://www.faqs.org/rfcs/rfc3339.html">RFC 3339</a>.</li> <li>Unless otherwise specified, all values must be plain text (i.e., no entity-encoded html).</li> <li><a href="http://www.w3.org/TR/REC-xml/#sec-lang-tag"><code>xml:lang</code></a> may be used to identify the language of any human readable text.</li> <li><a href="http://www.w3.org/TR/xmlbase/"><code>xml:base</code></a> may be used to control how relative <abbr title="Universal Resource Identifier">URI</abbr>s are resolved.</li> </ul> <h3>Sample feed<a id="sampleFeed" name="sampleFeed"> </a></h3> <pre><?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <title>Example Feed</title> <link href="http://example.org/"/> <updated>2003-12-13T18:30:02Z</updated> <author> <name>John Doe</name> </author> <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id> <entry> <title>Atom-Powered Robots Run Amok</title> <link href="http://example.org/2003/12/13/atom03"/> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> <updated>2003-12-13T18:30:02Z</updated> <summary>Some text.</summary> </entry> </feed> </pre> <h2>Elements of <feed></h2> A Feed consists of some metadata, followed by any number of entries. <h3>Required feed elements<a id="requiredFeedElements" name="requiredFeedElements"> </a></h3> <p>Here's a list of the required feed elements, each with a brief description, and an example.</p> <table cellspacing="10"> <tbody readability="6.5"><tr> <th>Element</th> <th>Description</th> </tr> <tr readability="7"> <td valign="top">id</td> <td valign="top" readability="5">Identifies the feed using a universally unique and permanent <abbr title="Universal Resource Identifier">URI</abbr>. If you have a long-term, renewable lease on your Internet domain name, then you can feel free to use your website's address. <pre><id>http://example.com/</id></pre></td> </tr> <tr readability="5.5"> <td valign="top">title</td> <td valign="top" readability="6">Contains a human readable title for the feed. Often the same as the title of the associated website. This value should not be blank. <pre><title>Example, Inc.</title></pre></td> </tr> <tr readability="4"> <td valign="top">updated</td> <td valign="top" readability="5">Indicates the last time the feed was modified in a significant way. <pre><updated>2003-12-13T18:30:02Z</updated></pre></td> </tr> </tbody></table> <h3>Recommended feed elements<a id="recommendedFeedElements" name="recommendedFeedElements"> </a></h3> Atom makes a number of additional requirements and recommendations for feed elements that you should to be aware of. They are as follows: <table cellspacing="10"> <tbody readability="4.4412724306688"><tr> <th>Element</th> <th>Description</th> </tr> <tr readability="6.4235294117647"> <td valign="top">author</td> <td valign="top" readability="5.9279279279279">Names one author of the feed. A feed may have multiple <code>author</code> elements. A feed must contain at least one <code>author</code> element unless <b>all</b> of the <code>entry</code> elements contain at least one <code>author</code> element. More info <a href="#person">here</a>. <pre><author>   <name>John Doe</name>   <email>JohnDoe@example.com</email>   <uri>http://example.com/~johndoe</uri> </author></pre></td> </tr> <tr readability="4.9206349206349"> <td valign="top">link</td> <td valign="top" readability="4.919028340081">Identifies a related Web page. The type of relation is defined by the <code>rel</code> attribute. A feed is limited to one <code>alternate</code> per <code>type</code> and <code>hreflang</code>. A feed should contain a link back to the feed itself. More info <a href="#link">here</a>. <pre><link rel="self" href="/feed" /></pre></td> </tr> </tbody></table> <h3>Optional feed elements<a id="optionalFeedElements" name="optionalFeedElements"> </a></h3> <p>Here's a list of optional feed elements.</p> <table cellspacing="10"> <tbody readability="12.321587867975"><tr> <th>Element</th> <th>Description</th> </tr> <tr readability="3.886524822695"> <td valign="top">category</td> <td valign="top" readability="4.8484848484848">Specifies a category that the feed belongs to. A <code>feed</code> may have multiple <code>category</code> elements. More info <a href="#category">here</a>. <pre><category term="sports"/></pre></td> </tr> <tr readability="3.9036144578313"> <td valign="top">contributor</td> <td valign="top" readability="4.8701298701299">Names one contributor to the feed. An feed may have multiple contributor elements. More info <a href="#person">here</a>. <pre><contributor>   <name>Jane Doe</name> </contributor></pre></td> </tr> <tr readability="6"> <td valign="top">generator</td> <td valign="top" readability="5">Identifies the software used to generate the feed, for debugging and other purposes. Both the <abbr title="Uniform Resource Identifier">uri</abbr> and <code>version</code> attributes are optional. <pre><generator uri="/myblog.php" version="1.0">   Example Toolkit </generator></pre></td> </tr> <tr readability="3"> <td valign="top">icon</td> <td valign="top">Identifies a small image which provides iconic visual identification for the feed. Icons should be square. <pre><icon>/icon.jpg</icon></pre></td> </tr> <tr readability="3"> <td valign="top">logo</td> <td valign="top">Identifies a larger image which provides visual identification for the feed. Images should be twice as wide as they are tall. <pre><logo>/logo.jpg</logo></pre></td> </tr> <tr readability="5.8235294117647"> <td valign="top">rights</td> <td valign="top" readability="4.8449612403101">Conveys information about rights, e.g. copyrights, held in and over the feed. More info <a href="#text">here</a>. <pre><rights> © 2005 John Doe </rights></pre></td> </tr> <tr readability="3.8888888888889"> <td valign="top">subtitle</td> <td valign="top" readability="4.8518518518519">Contains a human-readable description or subtitle for the feed. More info <a href="#text">here</a>. <pre><subtitle>all your examples are belong to us</subtitle></pre></td> </tr> </tbody></table> <h2>Elements of <entry></h2> An example of an entry would be a single post on a weblog. <h3>Required Elements of <entry><a id="requiredEntryElements" name="requiredEntryElements"> </a></h3> <p>Here's a list of the required feed elements, each with a brief description, and an example.</p> <table cellspacing="10"> <tbody readability="6.4637377963738"><tr> <th>Element</th> <th>Description</th> </tr> <tr readability="4.9280575539568"> <td valign="top">id</td> <td valign="top" readability="4.9272727272727">Identifies the entry using a universally unique and permanent <abbr title="Universal Resource Identifier">URI</abbr>. Suggestions on how to make a good id can be found <a href="https://web.archive.org/web/20110926231958/http://diveintomark.org/archives/2004/05/28/howto-atom-id">here</a>. Two entries in a feed can have the same value for id if they represent the same entry at different points in time. <pre><id>http://example.com/blog/1234</id></pre></td> </tr> <tr readability="4"> <td valign="top">title</td> <td valign="top" readability="5">Contains a human readable title for the entry. This value should not be blank. <pre><title>Atom-Powered Robots Run Amok</title></pre></td> </tr> <tr readability="7"> <td valign="top">updated</td> <td valign="top" readability="5">Indicates the last time the entry was modified in a significant way. This value need not change after a typo is fixed, only after a substantial modification. Generally, different entries in a feed will have different updated timestamps. <pre><updated>2003-12-13T18:30:02-05:00</updated></pre></td> </tr> </tbody></table> <h3>Recommended elements of <entry><a id="recommendedEntryElements" name="recommendedEntryElements"> </a></h3> Atom makes a number of additional requirements and recommendations for entry elements that you should to be aware of. They are as follows: <table cellspacing="10"> <tbody readability="11.336444444444"><tr> <th>Element</th> <th>Description</th> </tr> <tr readability="5.9210526315789"> <td valign="top">author</td> <td valign="top" readability="4.9326599326599">Names one author of the entry. An entry may have multiple authors. An entry must contain at least one <code>author</code> element unless there is an <code>author</code> element in the enclosing <code>feed</code>, or there is an <code>author</code> element in the enclosed <code>source</code> element. More info <a href="#person">here</a>. <pre><author>   <name>John Doe</name> </author></pre></td> </tr> <tr readability="5.8914027149321"> <td valign="top">content</td> <td valign="top" readability="4.906103286385">Contains or links to the complete content of the entry. Content must be provided if there is no <code>alternate</code> link, and should be provided if there is no <code>summary</code>. More info <a href="#content">here</a>. <pre><content>complete story here</content></pre></td> </tr> <tr readability="4.9283154121864"> <td valign="top">link</td> <td valign="top" readability="4.9270072992701">Identifies a related Web page. The type of relation is defined by the <code>rel</code> attribute. An entry is limited to one <code>alternate</code> per <code>type</code> and <code>hreflang</code>. An entry must contain an <code>alternate</code> link if there is no <code>content</code> element. More info <a href="#link">here</a>. <pre><link rel="alternate" href="/blog/1234"/></pre></td> </tr> <tr readability="9.8657718120805"> <td valign="top">summary</td> <td valign="top" readability="4.9310344827586">Conveys a short summary, abstract, or excerpt of the entry. Summary should be provided if there either is no content provided for the entry, or that content is not inline (i.e., contains a src attribute), or if the content is encoded in base64. More info <a href="#text">here</a>. <pre><summary>Some text.</summary></pre></td> </tr> </tbody></table> <h3>Optional elements of <entry><a id="optionalEntryElements" name="optionalEntryElements"> </a></h3> <p>Here's a list of optional feed elements.</p> <table cellspacing="10"> <tbody readability="8.8706586826347"><tr> <th>Element</th> <th>Description</th> </tr> <tr readability="3.891156462585"> <td valign="top">category</td> <td valign="top" readability="4.8550724637681">Specifies a category that the entry belongs to. A <code>entry</code> may have multiple <code>category</code> elements. More info <a href="#category">here</a>. <pre><category term="technology"/></pre></td> </tr> <tr readability="3.9047619047619"> <td valign="top">contributor</td> <td valign="top" readability="4.8717948717949">Names one contributor to the entry. An entry may have multiple <code>contributor</code> elements. More info <a href="#person">here</a>. <pre><contributor>   <name>Jane Doe</name> </contributor></pre></td> </tr> <tr readability="4"> <td valign="top">published</td> <td valign="top" readability="5">Contains the time of the initial creation or first availability of the entry. <pre><published>2003-12-13T09:17:51-08:00</published></pre></td> </tr> <tr readability="5.8509316770186"> <td valign="top">rights</td> <td valign="top" readability="4.8701298701299">Conveys information about rights, e.g. copyrights, held in and over the entry. More info <a href="#text">here</a>. <pre><rights type="html">   &amp;copy; 2005 John Doe </rights></pre></td> </tr> <tr readability="6"> <td valign="top">source</td> <td valign="top" readability="7">Contains metadata from the source feed if this entry is a copy. <pre><source>   <id>http://example.org/</id>   <title>Example, Inc.</title>   <updated>2003-12-13T18:30:02Z</updated> </source></pre></td> </tr> </tbody></table> <h2>Common Constructs</h2> <h3 id="category">Category<a name="category"> </a></h3> <p><code><category></code> has one required attribute, <code>term</code>, and two optional attributes, <code>scheme</code> and <code>label</code>.</p> <p><code>term</code> identifies the category</p> <p><code>scheme</code> identifies the categorization scheme via a <abbr title="Universal Resource Identifier">URI</abbr>. </p> <p><code>label</code> provides a human-readable label for display</p> <h3>Content<a id="contentElement" name="contentElement"> </a></h3> <p><code><content></code> either contains, or links to, the complete content of the entry.</p> <p>In the most common case, the <code>type</code> attribute is either <code>text</code>, <code>html</code>, <code>xhtml</code>, in which case the content element is defined identically to other text constructs, which are described <a href="#text">here</a>.</p> <p>Otherwise, if the <code>src</code> attribute is present, it represents the <abbr title="Universal Resource Identifier">URI</abbr> of where the content can be found. The <code>type</code> attribute, if present, is the media type of the content.</p> <p>Otherwise, if the <code>type</code> attribute ends in <code>+xml</code> or <code>/xml</code>, then an xml document of this type is contained inline.</p> <p>Otherwise, if the <code>type</code> attribute starts with <code>text</code>, then an escaped document of this type is contained inline.</p> <p>Otherwise, a <a href="http://www.faqs.org/rfcs/rfc3548.html">base64</a> encoded document of the indicated media type is contained inline.</p> <h3 id="link">Link<a name="link"> </a></h3> <p><code><link></code> is patterned after html's <a href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/links.html#h-12.3">link</a> element. It has one required attribute, <code>href</code>, and five optional attributes: <code>rel</code>, <code>type</code>, <code>hreflang</code>, <code>title</code>, and <code>length</code>.</p> <p><code>href</code> is the <abbr title="Universal Resource Identifier">URI</abbr> of the referenced resource (typically a Web page)</p> <p><code>rel</code> contains a single link relationship type. It can be a full <abbr title="Universal Resource Identifier">URI</abbr> (see <a href="#extensibility">extensibility</a>), or one of the following predefined values (default=<code>alternate)</code>:</p> <ul> <li><code>alternate</code>: an alternate representation of the entry or feed, for example a permalink to the html version of the entry, or the front page of the weblog.</li> <li><code>enclosure</code>: a related resource which is potentially large in size and might require special handling, for example an audio or video recording.</li> <li><code>related</code>: an document related to the entry or feed.</li> <li><code>self</code>: the feed itself.</li> <li><code>via</code>: the source of the information provided in the entry.</li> </ul> <p><code>type</code> indicates the media type of the resource.</p> <p><code>hreflang</code> indicates the language of the referenced resource.</p> <p><code>title</code> human readable information about the link, typically for display purposes.</p> <p><code>length</code> the length of the resource, in bytes.</p> <h3 id="person">Person<a name="person"> </a></h3> <p><code><author></code> and <code><contributor></code> describe a person, corporation, or similar entity. It has one required element, <code>name</code>, and two optional elements: <code>uri</code>, <code>email</code>.</p> <p><code><name></code> conveys a human-readable name for the person.</p> <p><code><uri></code> contains a home page for the person.</p> <p><code><email></code> contains an email address for the person.</p> <h3 id="text">Text<a name="text"> </a></h3> <p><code><title></code>, <code><summary></code>, <code><content></code>, and <code><rights></code> contain human-readable text, usually in small quantities. The <code>type</code> attribute determines how this information is encoded (default="text")</p> <p>If <code>type="text"</code>, then this element contains plain text with no entity escaped html.</p> <pre><title type="text">AT&amp;T bought by SBC!</title></pre> <p>If <code>type="html"</code>, then this element contains entity escaped html.</p> <pre><title type="html">   AT&amp;amp;T bought &lt;b&gt;by SBC&lt;/b&gt;! </title></pre> <p>If <code>type="xhtml"</code>, then this element contains inline xhtml, wrapped in a div element.</p> <pre><title type="xhtml">   <div xmlns="http://www.w3.org/1999/xhtml">     AT&amp;T bought <b>by SBC</b>!   </div> </title></pre> <h2 id="extensibility">Extending Atom<a name="extensibility"> </a></h2> <p>The atom content element is designed to support the direct inclusion of other XML vocabularies.</p> <p>Any fully qualified <abbr title="Universal Resource Identifier">URI</abbr> may be used a value for the rel attribute of <code>link</code> elements.</p> <p>Elements from other namespaces may be included pretty much anywhere. This means that most <a href="https://directory.google.com/Top/Reference/Libraries/Library_and_Information_Science/Technical_Services/Cataloguing/Metadata/RDF/Applications/RSS/Specifications/RSS_1.0_Modules/">RSS 1.0</a> and <a href="http://blogs.law.harvard.edu/tech/directory/5/specifications/rss20ModulesNamespaces">RSS 2.0</a> modules may be used in Atom.</p> <h2 id="seeAlso">See Also<a name="seeAlso"> </a></h2> <!-- .centered --> </div> </div> </div> </div> <div class='clear'></div> </div> <div style='position:fixed; bottom:0; left:0; right:0;'> </div> <div align='center' style='border-top:1px solid #EEE; padding:1em; margin-top:2em;'> 联系我们 contact @ memedata.com </div> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-PFMR8YTWGP"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-PFMR8YTWGP'); </script> </body> </html>