Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8923443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:07:14+00:00 2026-06-15T07:07:14+00:00

Can’t figure out why my loop duplicates the results? I trying to fetch RSS

  • 0

Can’t figure out why my loop duplicates the results?
I trying to fetch RSS feeds from the kalRss = rss url. It gets everything but it duplicates the entries in a weird way. If you look in the firebug console you can se that there is only 3 entries. http://www8.umu.se/project/rut/display/index.html

<script src="https://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
    google.load("feeds", "1");
    var kalRSS = "http://www.upc.umu.se/om-upc/kalendarium/prenumerera/kalender-rss/?categories=concert,conference,courseEducation,culturOnCampus,dissertation,exhibition,lecture,licentiateSeminar,meeting,theOthers,seminar,seminarSeries,workshop&whoCanAttend=employees&calendarIds=69&fromSiteNodeId=45897";
    function initialize() {
        console.log("initialize");
        var container = $('#dailyFeed');
        container.empty();
        //var feed = new google.feeds.Feed("http://fastpshb.appspot.com/feed/1/fastpshb");
        var feed = new google.feeds.Feed("http://www.upc.umu.se/om-upc/kalendarium/prenumerera/kalender-rss/?categories=concert,conference,courseEducation,culturOnCampus,dissertation,exhibition,lecture,licentiateSeminar,meeting,theOthers,seminar,seminarSeries,workshop&whoCanAttend=employees&calendarIds=69&fromSiteNodeId=45897");
        feed.setNumEntries(3);
        feed.load(function(result) {
            if (!result.error) {
                var html = '';
                var entryLenght = result.feed.entries.length;
                console.log("Number of posts: " + entryLenght);
                for (var i = 0; i < entryLenght; i++) {
                    console.log("Loop: " + i);
                    var entry = result.feed.entries[i];
                    console.log(entry);
                    var startTime = entry.content.substr(11, 5)
                    var endTime = entry.content.substr(27, 5)
                    html += '<li class="daily">';
                    html += '<h3 class="georgia">' + entry.title + '</h3>';
                    html += '<h4>' + entry.categories[0] + '</h4>';
                    html += '<p>Info: ' + entry.contentSnippet + '</p>';
                    html += '<p><img src="img/watch.png" class="icon" />' + startTime + ' - ' + endTime + '</p>';
                    html += '</li>';
                    container.append(html);
                }
            }
        });
    }
    google.setOnLoadCallback(initialize);
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:07:16+00:00Added an answer on June 15, 2026 at 7:07 am

    You are doing a html += "<li></li>" in your loop but you forget to reset this variable inside the loop. So on each iteration, the loop adds this to the container:

    • item 1
    • item 1, item 2
    • item 1, item 2, item 3

    End result:

    • item 1, item 1, item 2, item 1, item 2, item 3

    To fix, reset your html variable to "" at each iteration, e.g.:

    for (var i = 0; i < entryLenght; i++) {
        var html = '';
        // rest of your code
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can't seem to figure out what's wrong with the simple getJSON call below. It's
Can anyone help me trying to find out why this doesn't work. The brushes
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Can I prevent an .apk from being installed if unknown sources is checked?
Can any one help me in sorting this out in sed/awk/perl Input file Start
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Can you cast a List<int> to List<string> somehow? I know I could loop through
I am trying to loop through a bunch of documents I have to put

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.