Results 1 to 3 of 3

Thread: RSS to JavaScript

  1. #1
    Join Date
    Jan 2016
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation RSS to JavaScript

    Hello,
    How to add the date and a few words from articles to this javascript?
    // <div id="feeddiv"></div>

    Code:
    <script type="text/javascript" src="http://www.google.com/jsapi">
    </script>
    
    <script type="text/javascript">
    google.load("feeds", "1") //Load Google Ajax Feed API (version 1)
    </script>
    
    
    <div id="feed"></div>
    <script type="text/javascript">
    var feedcontainer=document.getElementById("feed")
    var feedurl="http://www.npr.org/rss/rss.php?id=1006"
    var feedlimit=10
    var rssoutput="<ul>"
    
    function rssfeedsetup(){
    var feedpointer=new google.feeds.Feed(feedurl)
    feedpointer.setNumEntries(feedlimit) 
    feedpointer.load(displayfeed) 
    }
    
    function displayfeed(result){
    if (!result.error){
    var thefeeds=result.feed.entries
    for (var i=0; i<thefeeds.length; i++)
    rssoutput+="<li><a href='" + thefeeds[i].link + "'>" + thefeeds[i].title + "</a></li>"
    rssoutput+="</ul>"
    feedcontainer.innerHTML=rssoutput
    }
    else
    alert("Error fetching feeds!")
    }
    
    window.onload=function(){
    rssfeedsetup()
    }
    
    </script> //
    Last edited by ddadmin; 01-13-2016 at 09:49 PM.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Take a look at the following page: http://www.javascriptkit.com/dhtmltu...jaxfeed2.shtml You can access thefeeds[i].content or thefeeds[i].contentSnippet to display a portion of each entry's description/ content.
    DD Admin

  3. #3
    Join Date
    Jan 2016
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you! That helps! But one more question...How can I take certain tags out of this NPR feed? For example, I want just news with tags "space", or "science".

Similar Threads

  1. Replies: 4
    Last Post: 02-11-2008, 02:38 PM
  2. Javascript.AJAX link inside javascript dropdownmenu
    By Possemaster in forum JavaScript
    Replies: 2
    Last Post: 01-25-2008, 09:46 AM
  3. 3rd javascript not supporting in side the javascript program
    By raju in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 03-24-2007, 10:34 AM
  4. [Ajax XML Ticker ] javascript execute in javascript
    By Borsti26 in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 02-21-2007, 04:33 PM
  5. [Javascript] Class-Based Javascript Analog Clock
    By ByteMyCode in forum Submit a DHTML or CSS code
    Replies: 2
    Last Post: 10-14-2006, 10:13 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •