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.

38 lines
1.2 KiB

  1. function JRss(xml) {
  2. this._parse(xml);
  3. };
  4. JRss.prototype = {
  5. _parse: function(xml) {
  6. if(jQuery('rss', xml).length == 0) this.version = '1.0';
  7. else this.version = jQuery('rss', xml).eq(0).attr('version');
  8. var channel = jQuery('channel', xml).eq(0);
  9. this.title = jQuery(channel).find('title:first').text();
  10. this.link = jQuery(channel).find('link:first').text();
  11. this.description = jQuery(channel).find('description:first').text();
  12. this.language = jQuery(channel).find('language:first').text();
  13. this.updated = jQuery(channel).find('lastBuildDate:first').text();
  14. this.items = new Array();
  15. var feed = this;
  16. jQuery('item', xml).each( function() {
  17. var item = new JFeedItem();
  18. item.title = jQuery(this).find('title').eq(0).text();
  19. item.link = jQuery(this).find('link').eq(0).text();
  20. item.description = jQuery(this).find('description').eq(0).text();
  21. item.updated = jQuery(this).find('pubDate').eq(0).text();
  22. item.id = jQuery(this).find('guid').eq(0).text();
  23. feed.items.push(item);
  24. });
  25. }
  26. };