Could someone please help me understand what the “link” tags are used for within an ATOM feed?
Any information regarding this would be much appreciated!
I have provided an example snippet of code below.
<?xml version="1.0"?>
<atom:feed>
<link rel="self" href="http://publisher.example.com/happycats.xml" />
<updated>2008-08-11T02:15:01Z</updated>
<!-- Example of a full entry. -->
<entry>
<title>Heathcliff</title>
<link href="http://publisher.example.com/happycat25.xml" />
<id>http://publisher.example.com/happycat25.xml</id>
<updated>2008-08-11T02:15:01Z</updated>
<content>
What a happy cat. Full content goes here.
</content>
</entry>
Atom is a syndication format that can be used by applications employing ReSTful communication through hypermedia. It's very good for publication of feeds, which is not only for blogs but can also be used in distributed applications (for example, for publishing events to other parts of a system) to utilise the benefits of HTTP (caching, scalability, etc) and the decoupling involved in using REST.
elements in Atom are called link relations and can indicate to the consumer of the feed a number of things:
rel="self"
normally indicates that the current element (in your case, the feed itself) represents an actual resource, and this is the URI for that resourcerel="via"
can identify the original source of the information in the feed or the entry within the feedrel="alternate"
specifies a link to an alternative representation of the same resource (feed or entry)rel="enclosure"
can mean that the linked to resource is intended to be downloaded and cached, as it may be largerel="related"
indicates the link is related to the current feed or entry in some wayrel
valueBy providing links to related resources in this way you can decouple systems - the only URI the system needs to know about is 1 entry point, and from then on other actions are provided to the consumer via these link relations. The links effectively tell the consumer that they can use these links to either take actions on or retrieve data for the entry they are related to.
A great book I can recommend for REST which goes into depth about Atom is REST in Practice by Jim Webber, Savas Parastatidis and Ian Robinson.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With