how to dynamically read RSS using jquery


/ Published in: jQuery
Save to your folder(s)



Copy this code and paste it in your HTML
  1. //The easiest way would be to use the Google AJAX Feed API. They have a really simple example, which suits what you want nicely:
  2.  
  3. <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  4. <script type="text/javascript">
  5.  
  6. google.load("feeds", "1");
  7.  
  8. function initialize() {
  9. var feed = new google.feeds.Feed("http://www.digg.com/rss/index.xml");
  10. feed.load(function(result) {
  11. if (!result.error) {
  12. var container = document.getElementById("feed");
  13. for (var i = 0; i < result.feed.entries.length; i++) {
  14. var entry = result.feed.entries[i];
  15. var div = document.createElement("div");
  16. div.appendChild(document.createTextNode(entry.title));
  17. container.appendChild(div);
  18. }
  19. }
  20. });
  21. }
  22. google.setOnLoadCallback(initialize);
  23.  
  24. </script>
  25. <div id="feed"></div>
  26.  
  27. //Of course, you can mix jQuery with the API instead of using native DOM calls.

URL: http://stackoverflow.com/questions/2323041/how-to-dynamically-read-rss-using-jquery

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.