0

I m trying to display RSS data on page using jQuery, So I have used below URL in my code and it is working fine to display feed from outside SharePoint sites.

"https://feed.jquery-plugins.net/load?url=" + encodeURIComponent("feedURL") + "&maxCount=" + def.MaxCount + "&dateCulture=" + def.DateFormatLang + "&dateFormat=" + def.DateFormat"

But in SharePoint, this is giving error.

{"statusCode":400,"errorMessage":"ERROR_ON_GETTING_FEEDS : '>' is an unexpected token. The expected token is '='. Line 11, position 72.","data":null}

url for SharePoint is:

url: "https://feed.jquery-plugins.net/load?url=https://test.sharepoint.com/sites/DeveloperSite/_layouts/15/listfeed.aspx?List=f3d7161e-2f6d-4c6e-8d7d-1721e8b70ef0&View=5d658d21-4804-47d9-b993-0752aeb8feb5",

1

If you want to show the list RSS Feed in SharePoint page, we can use the code below to achieve it.

<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {  
    $.ajax({
        url: _spPageContextInfo.webAbsoluteUrl + "/_layouts/15/listfeed.aspx?List=f3d7161e-2f6d-4c6e-8d7d-1721e8b70ef0&View=5d658d21-4804-47d9-b993-0752aeb8feb5",
        type: "GET",
        headers: {
            "Accept": "application/rss+xml",
        },
        dataType:"xml",
        success: function (data){
            $(data).find("item").each(function () {          
                var html="<p><a href='"+$(this).find("link").text()+"'>"+$(this).find("title").text()+"</a><br/>";
                html+=""+$(this).find("description").text()+"</p>";
                $("#showListRSSFeed").append(html);
            });
        },
        error: function (data) {
            //alert("Error");
        }
    }); 
})
</script>
<div id="showListRSSFeed"/>

If you want to access SharePoint list RSS Feed in external site, the code will not works, SharePoint online don't allow you anonymous access list RSS Feed.

2
  • can we also apply filters in url?
    – KumarV
    Sep 9 '19 at 6:01
  • You can filter the data in the success method, we can't add the $filter like in REST API in listfeed.aspx request.
    – LZ_MSFT
    Sep 9 '19 at 8:46
1

I don't think that you do what you want to do.

Here, you retrieve the output of an RSS reader. This Rss Reader reads for you files/stream that it can read : public rss feed.

Yours is private, and this tool have no access to it.

If you want to read rss, put this snippet on your page instead :

$(document).ready(function() {
//feed to parse
var feed = "https://test.sharepoint.com/sites/DeveloperSite/_layouts/15/listfeed.aspx?List=f3d7161e-2f6d-4c6e-8d7d-1721e8b70ef0&View=5d658d21-4804-47d9-b993-0752aeb8feb5";

$.ajax(feed, {
    accepts:{
        xml:"application/rss+xml"
    },
    dataType:"xml",
    success:function(data) {
        //Credit: http://stackoverflow.com/questions/10943544/how-to-parse-an-rss-feed-using-javascript

        $(data).find("item").each(function () { // or "item" or whatever suits your feed
            var el = $(this);
            console.log("------------------------");
            console.log("title      : " + el.find("title").text());
            console.log("link       : " + el.find("link").text());
            console.log("description: " + el.find("description").text());
        });


    }   
});

});

Source : https://www.raymondcamden.com/2015/12/08/parsing-rss-feeds-in-javascript-options

you can go with more modern javascript (and less jquery) as well ;) => source : https://www.hongkiat.com/blog/rss-reader-in-javascript/

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.