A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: RSS Feed javascript

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Location
    Lillestrøm, Norway
    Posts
    21

    RSS Feed javascript

    Does anyone know if there is a way to get this script to show the entire feed including images?

    Code:
      <head>
        <script type="text/javascript" src="http://www.google.com/jsapi?key=MYKEY"></script>
        <script type="text/javascript">
    
        google.load("feeds", "1");
    
        function initialize() {
          var feed = new google.feeds.Feed("http://thedosblogger.blogspot.com/atom.xml");
          feed.load(function(result) {
            if (!result.error) {
              var container = document.getElementById("feed");
              for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                var div = document.createElement("div");
                div.appendChild(document.createTextNode(entry.title));
                container.appendChild(div);
              }
            }
          });
        }
        google.setOnLoadCallback(initialize);
    
        </script>
      </head>
      <body>
        <div id="feed"></div>
      </body>

  2. #2
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    Well the best thing to do would be to read the Google Feeds documentation...

    http://code.google.com/apis/ajaxfeed...reference.html

    Code:
    function initialize() {
          var feed = new google.feeds.Feed("http://thedosblogger.blogspot.com/atom.xml");
          feed.load(function(result) {
            if (!result.error) {
              var container = document.getElementById("feed");
              for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                var div = document.createElement("div");
    			var content=document.createElement("div");
    			content.innerHTML=entry.content
                div.appendChild(content);
                container.appendChild(div);
              }
            }
          });
        }

  3. #3
    Junior Member
    Join Date
    Sep 2008
    Location
    Lillestrøm, Norway
    Posts
    21
    It did and I tried a lot of things, but most of it was greek to me

    Thank you for your help rdoyle720

  4. #4
    Junior Member
    Join Date
    Sep 2008
    Location
    Lillestrøm, Norway
    Posts
    21
    Hmmm... How do I add title and publishedDate to that? Now it only shows content.
    I looked at another script example and there it shows
    Code:
    var attributes = ["title", "content", "publishedDate"];
    Is there a way to add that to the script?

  5. #5
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    Yep, each item is an entry, and it's showing the content by getting entry.content. So to get the title, you'd get entry.title and entry.publishedDate.

    Code:
     function initialize() {
          var feed = new google.feeds.Feed("http://thedosblogger.blogspot.com/atom.xml");
          feed.load(function(result) {
            if (!result.error) {
              var container = document.getElementById("feed");
              for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                var div = document.createElement("div");
    			var content=document.createElement("div");
    			content.innerHTML=entry.title+"<br>"+entry.publishedDate+"<br>"+entry.content
                div.appendChild(content);
                container.appendChild(div);
              }
            }
          });
        }

  6. #6
    Junior Member
    Join Date
    Sep 2008
    Location
    Lillestrøm, Norway
    Posts
    21
    Aha! I think I'm starting to understand and it's wasn't as hard as I thought it was. All I neded was to add ""+ +""

    Thank you so much rdoyle720. You have really helped me out
    Been working on this problem since yesterday

  7. #7
    Junior Member
    Join Date
    Sep 2008
    Location
    Lillestrøm, Norway
    Posts
    21
    Can anyone explane to me how it comes that it only shows the first four entries? It doesn't show the entire rss feed. That was kinda strange

  8. #8
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    From the page linked above: "By default, the FeedControl class loads 4 entries from each feed." It's likely for performance so it doesn't load a billion entries.

    Code:
        function initialize() {
          var feed = new google.feeds.Feed("http://thedosblogger.blogspot.com/atom.xml");
     	feed.setNumEntries(10); // change this number to whatever you want
          feed.load(function(result) {
            if (!result.error) {
              var container = document.getElementById("feed");
              for (var i = 0; i < result.feed.entries.length; i++) {
                var entry = result.feed.entries[i];
                var div = document.createElement("div");
    			var content=document.createElement("div");
    			content.innerHTML=entry.title+"<br>"+entry.publishedDate+"<br>"+entry.content
                div.appendChild(content);
                container.appendChild(div);
              }
            }
          });
        }

  9. #9
    Junior Member
    Join Date
    Sep 2008
    Location
    Lillestrøm, Norway
    Posts
    21
    You're a genius rdoyle720

  10. #10
    Registered User
    Join Date
    Feb 2010
    Location
    comilla city
    Posts
    1
    webpage to help me create a ticker style rss feed that keeps flicking through the feeds. It uses Javascript. If you know a bit about both ... pass a little html in the description. your feeds are rss 2.0.... old as far as standards..


    Thanks

    Mangerpola


    _______________________

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center