﻿function get_r6_feed(elementIdentifier, url, numOfElements) {
    var html = '';
    //use the JQuery get to grab the URL from the item
    jQuery.ajaxSetup({cache: false});
    jQuery.get(url, function(d) {
        //find each 'article' in the file and parse it
        jQuery(d).find('article').each(function(index) {
            if (index >= numOfElements) {
                return false;
            }
            //name the current found item this for this particular loop run
            var $article = jQuery(this);
            var $desc = $article.find('description');

            // grab the headline
            var title = $desc.find('headline').text();
            // next, the description
            var description = $desc.find('description').text();
            var content = $desc.find('content').text();

            // grab the post's URL
            var link = $article.find('article_url').text();
            //and the pubdate
            var pubDate = $article.find('publish_date').text();

            //form the link
            html += '<li><a href="';
            html += link + '" target="_blank" >' + title + " : " + content;
            html += '</a></li>' + "\n";

        });
        //clear the content in the ul each time.
        jQuery(elementIdentifier).empty();
        //put the feed content on the screen.
        jQuery(elementIdentifier).append(html);
    });

};

