2013-05-08 45 views
0

工作我使用jGFeed解析RSS源,我爲此代碼如下:entry.description;不jGFeed

$.jGFeed('http://feeds.bbci.co.uk/news/rss.xml', 
      function(feeds){ 
      // Check for errors 
      if(!feeds){ 
       // there was an error 
       return false; 
      } 
      // do whatever you want with feeds here 
      $('#newsTimeline').empty(); 
      for(var i=0; i<feeds.entries.length; i++){ 
       var entry = feeds.entries[i]; 
       var title = entry.title; 
       var description = entry.description; 
       var linkUrl = entry.link_url; 
       var date = getDate(entry.pubDate); 
       var time = getTime(entry.pubDate); 
       $('#newsTimeline').append('<li><time class="cbp_tmtime" datetime="'+date+' '+time+'"><span>'+date+'</span> <span>'+time+'</span></time><div class="cbp_tmicon cbp_tmicon-phone"></div><div class="cbp_tmlabel"><h2>'+title+'</h2><p>'+description+'</p></div></li>'); 
      } 
     }, 10); 

的問題是,它正在爲entry.title,但沒有之後的作品: The final page


注意:在Javascript控制檯中不記錄錯誤。

+0

如何數組看?你可以發佈樣本嗎? – Omar 2013-05-08 13:22:18

+0

@Omar這裏是一個截圖http://blog.bobcravens.com/content/binary/WindowsLiveWriter/BuildanRSSFeedReaderwithjQueryandjGFeed_13A47/image_4.png – 2013-05-08 13:35:03

+0

我不能看到描述,至少要發佈一個數組/對象。 – Omar 2013-05-08 13:42:59

回答

3

試試這個

 for(var i=0;i<feeds.entries.length;i++){ 
      var entry = feeds.entries[i]; 
      var title = entry.title; 
      var linkUrl= entry.link; 
      var description = entry.contentSnippet; 
      var date = entry.publishedDate; 
      $('#newsTimeline').append('<li><time class="cbp_tmtime" datetime="'+date+'  '+time+'"><span>'+date+'</span> <span>'+time+'</span></time><div class="cbp_tmicon cbp_tmicon-phone"></div><div class="cbp_tmlabel"><h2>'+title+'</h2><p>'+description+'</p></div></li>'); 
      } 
相關問題