jQuery RSS/ATOM feed parser plugin
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.7 KiB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <title>jFeed - jQuery feed parser plugin - example</title>
  7. <style type="text/css">
  8. h3 { margin-bottom: 5px; }
  9. div.updated { color: #999; margin-bottom: 5px; font-size: 0.8em; }
  10. </style>
  11. <script type="text/javascript" src="jquery/jquery.js"></script>
  12. <script type="text/javascript" src="build/dist/jquery.jfeed.pack.js"></script>
  13. <script type="text/javascript">
  14. jQuery(function() {
  15. jQuery.getFeed({
  16. url: 'xml/rss-20.xml',
  17. success: function(feed) {
  18. jQuery('#result').append('<h2>'
  19. + '<a href="'
  20. + feed.link
  21. + '">'
  22. + feed.title
  23. + '</a>'
  24. + '</h2>');
  25. var html = '';
  26. for(var i = 0; i < feed.items.length && i < 5; i++) {
  27. var item = feed.items[i];
  28. html += '<h3>'
  29. + '<a href="'
  30. + item.link
  31. + '">'
  32. + item.title
  33. + '</a>'
  34. + '</h3>';
  35. html += '<div class="updated">'
  36. + item.updated
  37. + '</div>';
  38. html += '<div>'
  39. + item.description
  40. + '</div>';
  41. }
  42. jQuery('#result').append(html);
  43. }
  44. });
  45. });
  46. </script>
  47. </head>
  48. <body>
  49. <h1>jFeed - jQuery feed parser plugin - example</h1>
  50. <div id="result" />
  51. </body>
  52. </html>