Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I put this RSS feed in a jQuery listview?

Okay I found this RSS plugin and I want to display it inside a webpage, but I want it to be in a jQuery listview, so each item is a list item, could someone please explain to me how to do it? I put the jsfiddle link below! Thanks
http://jsfiddle.net/8qhZP/
And this is the actual source where I found the plugin
http://www.jquery4u.com/plugins/jquery-rss-feed-display-live/

like image 917
William Lewis Avatar asked Dec 26 '11 19:12

William Lewis


1 Answers

Easiest way to accomplish this is to get the RSS feed converted into a JSON object. This way you can call the url using JSONP and then parse the output using a jQuery template engine.

1) Convert the RSS feed into a JSON feed using Yahoo pipes (can also combine RSS feeds)

http://jquery4u.com/rss/

into

Yahoo JSON Pipe Output

2) Render the JSON feed using a jQuery templating engine like json2html

<script src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script src="http://json2html.com/js/jquery.json2html-2.5-min.js"></script>

<script type="text/javascript">
var transform = {tag:'li',children:[
                    {tag:'a',src:'.link',html:'.title'},
                    {tag:'br'},
                    {tag:'span',html:'.description'}
                ]};

$.getJSON("http://pipes.yahoo.com/pipes/pipe.run?_callback=?", {"_id":"f5e0edec7594378e719cf18c53f8a26c","_render":"json"}, function(data){
    $('#rssFeed').json2html(data.value.items,transform);
});   
</script>

<ul id='rssFeed'></ul>
like image 191
Chad Brown Avatar answered Sep 28 '22 05:09

Chad Brown