Posted By

olemedia on 06/03/11


Tagged

rss jquery read


Versions (?)

how to dynamically read RSS using jquery


 / Published in: jQuery
 

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

  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.

Report this snippet  

You need to login to post a comment.