For all your music news related needs


Week 10:

RSS (Rich Site Summary) (or Really Simple Syndication) is an XML format which allows its users to keep up-to-date with several sites on the internet which otherwise may be difficult to do across a large spectrum of sites. It is commonplace for blogs or news related sites to have RSS feeds. Typically, users will find RSS feeds from sites they have interest in and add the feed to a client of sorts which allows the user to keep up-to-date with the latest posts from said sites. RSS feeds allow users to spend less time trolling through a large array of sites, enabling them to see the content they want to see.

Making use of RSS feeds from your site could mean additional traffic which is why a large percentage of sites online offer this service. These services can often be found on the site itself or simply by using a search engine and searching the site’s name + RSS.

Another attraction to using RSS feeds is that you are saved from needing to sign up to a site’s newsletter. A multitude of massive online organisations make use of RSS feeds including Yahoo, BBC, Apple, Oracle, The Guardian, Sky News, Techworld, and IEEE Spectrum to name a few.

It is important that a site’s RSS feed is up-to-date with the regular changes of content, this can be done through a range of methods each with varying level of intricacy. A common way to do this is to have a file which ensures the RSS feed is up to date each time it is executed. A PHP file can be in place to generate or overwrite a permalinked RSS XML file. This is commonly done by reading the database details on current posts or site additions and building a file through XML DOM. This is then pushed to overwrite the existing RSS XML file which inherently ensures that this RSS feed is delivering up-to-date information in the expected format.

In addition to RSS readers or clients, RSS feeds can be used to provide users of a website with additional and external information they otherwise may not have received. RSS feeds can offer you the ability to add external data or posts in a familiar and fitting format.

PHP has a large selection of XML related functions which can help developers build solutions for both implementing an external RSS feed and additionally for creating their own RSS feed for others to make use of. DOM (Document Object Model) allows developers to work in close accuracy with and build in DOM parsers make it easy to process XML documents within PHP.

DOM can be used in the example seen below, allowing the developer to accurately build the desired layouts.

$dom = new DOMDocument('1.0', 'utf-8');

$dom->formatOutput = true;

$root = $dom->createElement('rss');

$dom->appendChild($root);

$version = $dom->createAttribute("version");

$root->appendChild($version);

$versionValue = $dom->createTextNode("2.0");

$version->appendChild($versionValue);

In order to save this as an XML file for further usage, the following code can be used:
echo $dom->save('rssFeed.xml');

The RSS feed can be found here.

Usage of an external RSS feed (Pitchfork) can be found here.

word count: 480