Switch to full style
JQuery Examples
Post a reply

Load RSS feeds and parse it with JQuery

Thu Jan 10, 2013 2:00 am

Read RSS feeds of any website and parse it with JQuery then print it into your webpage
javascript code
<html>
<head>
<title>Parse RSS feeds, load RSS.xml files</title>

<!--
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
Note you can download the JQuery package instead of using Google version. -->
<script src="jquery-1.8.3.js"></script>
<script type="text/javascript" src="./jFeed/build/dist/jquery.jfeed.pack.js"></script>
<script>

$(document).ready(function(){
$("button#btn1").click(function(){
loadRSS();
});
function loadRSS(){

$.getFeed({
// Note here we use php page and send the the URL to it as parameter.
url: 'getRSS.php?url=http://www.codemiles.com/rss.php',
success: function(feedObj) {

//Title and link
$('#RSSFeeds').append('<h1><a href="' + feedObj.link + '">' + feedObj.title + '</a>' + '</h1>');

//Print the list of feeds as read.
var contentRSS = '<ul>';

$(feedObj.items).each(function(){
var $singleFeed = $(this);

contentRSS += '<li>' +
'<h2><a href ="' + $singleFeed.attr("link") + '" >' + $singleFeed.attr("title") + '</a></h2> ' +
'<p>' + $singleFeed.attr("description") + '</p>' +
'<p>' + $singleFeed.attr("c:date") + '</p>' +
'</li>';
});

contentRSS += '</ul>';

$('#RSSFeeds').append(contentRSS);
}
});
}
});

</script>
</head>
<body>

<div id="RSSFeeds" ></div>
<button id="btn1">Load Feeds</button>
</body>
</html>


This JQuery call getRSS.php:
php code
<?php
// Get URL parameter value
if (!isset($_REQUEST["url"])) exit;

$url = $_REQUEST["url"];
// make sure that HTTP part exists.
if (substr($url, -0, 7) != "http://") exit;

echo file_get_contents($url);
?>



To download JFeeds
jfeed.zip
JFeeds
(45.49 KiB) Downloaded 725 times

or from its original source :
Code:
http://www.hovinne.com/blog/index.php/2007/07/15/132-jfeed-jquery-rss-atom-feed-parser-plugin




Post a reply
  Related Posts  to : Load RSS feeds and parse it with JQuery
 Load tweets using JQuery     -  
 Load Content to Tabs using AJAX and JQuery     -  
 Load file and update content using AJAX and JQuery     -  
 Parsing and Reading RSS feeds     -  
 Parsing ATOM feeds     -  
 parse XML file using SAX     -  
 Web scraping and Parse using java... plz help i really need.     -  
 Parse XML using DOM file and run XPath query     -  
 Parse URL in java get Protocol,File,Reference,Host and Port     -  
 load class to applet- load frame class to applet     -  

Topic Tags

JQuery GET/POST