Display RSS Feed Using JavaScript-RSS Feed JavaScript Reader

Converting RSS Feed to HTML using JavaScript will help us to display the feed in your Website or Blog’s sidebar or widget. In this article we discuss bout a very simple RSS JavaScript Feed Reader. This JavaScript feed reader can be used to display your favorite feed in your page. The RSS feed reader will parse the XML feed and will convert into HTML. This HTML will be rendered as the content of a <DIV> element.
The RSS Feed Reader JavaScript utilizes the “XMLHttpRequest” or the ActiveXObject “Microsoft.XMLHTTP” libraries depending on the browser you use. This article focuses on how to parse the RSS feed XML and convert into corresponding HTML.Related

If you are using this code please ensure that you do proper testing before adding to your website or blog. You can apply CSS styles that suites your website color and layout. The following RSS Reader Script will display the feed as below.

RSS JavaScript Reader

This is a simple function which fetches the RSS Feed from a URL and parses it. There are three main sections

In the above example we have used the Globinch.com RSS feed which is served from Google Feedburner. You need to replace “http://feeds.feedburner.com/globinch?format=xml” with the Feed URL that you want to display. The line “xmlDoc=xmlhttp.responseXML; ” retrieves the response XML from the XMLHttpRequest object.

Process the RSS Feed XML

Once the feed is retrieved you can start processing the feed. The “getElementsByTagName” method of XMLDoc object can be used to retrieve the XML elements present in the feed. For example if your feed is served from Google Feedburner you can use the below given code to process the XML.

In the above code based on the structure of the XML feed you may need to change the getElementsByTagName() method parameter name. We are building an HTML table using the Title, Description and Link fields from the RSS feed. The last line is to set the Value of the DIV as the processed RSS feed HTML. The parameter “param” is the JavaScript function parameter which will be passed from where the function is invoked.

Add the RSS Feed HTML to your Website

The below given example defines a DIV element which is a place holder for the processed RSS Feed HTML.

Our Readers Also Searched:

https://www.globinch.com/display-rss-feed-using-javascript-rss-feed-javascript-reader/2011-05-20T17:53:30+00:00Binu GeorgeWebsite Optimizationfeed reader,feed to javascript,how-to guides,javascript display rss,javascript feed reader,javascript rss feeds,productivity,rss feed html,rss feed reader,rss javascript reader,rss to javascriptConverting RSS Feed to HTML using JavaScript will help us to display the feed in your Website or Blog's sidebar or widget. In this article we discuss bout a very simple RSS JavaScript Feed Reader. This JavaScript feed reader can be used to display your favorite feed in your...Binu GeorgeBinuGeorgebinugeorgep@gmail.comAdministratorBinu George , the author of Globinch.com, is a technology blogger from India and a software solution architect by profession.Globinch