Rss Feeds RRS feed

  • Question

  • I have finally worked through the tutorial for building a blog reader. I can't provide a link and the code is quite extensive. If you do a search for "Windows apps javascript blog reader" it will bring up the tutorial.

    It works great with the links provided which are atom links. And it is a really nice design that I would like to use and modify. However, I am stuck. I cannot use xml rss feeds. Only atom. I have read the code until my eyes crossed and I can't see why not. I even searched for a way to convert xml to rss and could find nothing except FeedBurner and I really don't want to use that. It seems that there is a simple little thing I am just missing but I am stumped. Can someone tell me why this code behaves like this? The functions for the feed are on the data.js page. Thank you

    Monday, May 12, 2014 7:22 PM

All replies

  • Have you looked at the AtomPub sample and see if it fits your needs: http://code.msdn.microsoft.com/windowsapps/AtomPub-sample-c1fcdc8e

    Windows Store Developer Solutions, follow us on Twitter: @WSDevSol|| Want more solutions? See our blog

    Tuesday, May 13, 2014 12:59 AM
  • Thanks for the quick reply. I am trying to get feeds other than atom to work. Atom feeds do work. I have used JSON in the past with no problems. This is XHR and I'm trying to figure it out. It won't accept anything but atom feeds. It throws an exception after the parsing if I put a non Atom feed in there. I have stared at that code for a long time and I can't see why it wouldn't work. I have read MSDN articles and tried different things with no luck. I really don't know why it doesn't work. That's why I posted here. So someone smarter than me can look at it and see the issue immediately because I sure can't.
    Tuesday, May 13, 2014 10:54 AM
  • You'll get better answers if you include all of the relevant information in your post.

    The SyndicationFeed documentation states: The only formats accepted by this method are Atom 1.0 and RSS 2.0

    If you're trying to use a different format then that isn't expected to work. If not, then please show what you are doing and the feed you are trying to connect to.

    Tuesday, May 13, 2014 3:23 PM
  • This is the exact code from the tutorial from MSDN which is supposed to be for Windows 8.1 in the data.js page. I deleted some of the blogs for readability. There were 11. They're all atom feeds. I put the first one in which is xml and breaks it. I bolded the line where the error occurs. The message is "SCRIPT5007: Exception is about to be caught by JavaScript library code at line 123, column 25 in ms-appx://86c55b0a-ab9b-4a4f-971b-69251d1674d1/js/data.js 0x800a138f - JavaScript runtime error: Unable to get property 'textContent' of undefined or null reference File: data.js, Line: 123, Column: 25." If I put a break point there I get the same as a warning. I took out the ".textContent" and used intellisense and any possible additions were flagged with warning symbols. So I just removed it and got this message which may or may not be relevant: "The method Windows.UI.ViewManagement.ApplicationView.get_Value has been deprecated. Value may be altered or unavailable for releases after Windows 8.1. Instead, query for window layout sizes directly." Using atom feeds, there is no problem at all running this. I don't see why it wouldn't recognize xml too.

    (function () {
        "use strict";
        // Set up array variables
        var dataPromises = [];
        var blogs;
        // Create a data binding for our ListView
        var blogPosts = new WinJS.Binding.List();
        // Process the blog feeds
        function getFeeds() {
            // Create an object for each feed in the blogs array
            // Get the content for each feed in the blogs array
            // Return when all asynchronous operations are complete
            // Create an object for each feed in the blogs array
            blogs = [
                key: "blog1",
                url: 'http://www.bookreporter.com/reviews/rss.xml',
                title: 'tbd', updated: 'tbd',
                acquireSyndication: acquireSyndication, dataPromise: null
                key: "blog2",
                url: 'http://blogs.windows.com/windows/b/extremewindows/atom.aspx',
                title: 'tbd', updated: 'tbd',
                acquireSyndication: acquireSyndication, dataPromise: null
                key: "blog3",
                url: 'http://blogs.windows.com/windows/b/business/atom.aspx',
                title: 'tbd', updated: 'tbd',
                acquireSyndication: acquireSyndication, dataPromise: null
            // Get the content for each feed in the blogs array
            blogs.forEach(function (feed) {
                feed.dataPromise = feed.acquireSyndication(feed.url);
            // Return when all asynchronous operations are complete
            return WinJS.Promise.join(dataPromises).then(function () {
                return blogs;
        function acquireSyndication(url) {
            // Call xhr for the URL to get results asynchronously
            return WinJS.xhr(
                    url: url,
                    headers: { "If-Modified-Since": "Mon, 27 Mar 1972 00:00:00 GMT" }
        function getBlogPosts() {
            // Walk the results to retrieve the blog posts
            getFeeds().then(function () {
                // Process each blog
                blogs.forEach(function (feed) {
                    feed.dataPromise.then(function (articlesResponse) {
                        var articleSyndication = articlesResponse.responseXML;
                        if (articleSyndication) {
                            // Get the blog title 
                            feed.title = articleSyndication.querySelector("feed > title").textContent;
                            // Use the date of the latest post as the last updated date
                            var published = articleSyndication.querySelector("feed > entry > published").textContent;
                            // Convert the date for display
                            var date = new Date(published);
                            var dateFmt = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter(
                               "month.abbreviated day year.full");
                            var blogDate = dateFmt.format(date);
                            feed.updated = "Last updated " + blogDate;
                            // Get the blog posts
                            getItemsFromXml(articleSyndication, blogPosts, feed);
                        else {
                            // There was an error loading the blog. 
                            feed.title = "Error loading blog";
                            feed.updated = "Error";
                                group: feed,
                                key: "Error loading blog",
                                title: feed.url,
                                author: "Unknown",
                                month: "?",
                                day: "?",
                                year: "?",
                                content: "Unable to load the blog at " + feed.url
            return blogPosts;
        function getItemsFromXml(articleSyndication, bPosts, feed) {
            // Get the info for each blog post
            var posts = articleSyndication.querySelectorAll("entry");
            // Process each blog post
            for (var postIndex = 0; postIndex < posts.length; postIndex++) {
                var post = posts[postIndex];
                // Get the title, author, and date published
                var postTitle = post.querySelector("title").textContent;
                var postAuthor = post.querySelector("author > name").textContent;
                var postPublished = post.querySelector("published").textContent;
                // Convert the date for display
                var postDate = new Date(postPublished);
                var monthFmt = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter(
                var dayFmt = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter(
                var yearFmt = new Windows.Globalization.DateTimeFormatting.DateTimeFormatter(
                var blogPostMonth = monthFmt.format(postDate);
                var blogPostDay = dayFmt.format(postDate);
                var blogPostYear = yearFmt.format(postDate);
                // Process the content so it displays nicely
                var staticContent = toStaticHTML(post.querySelector("content").textContent);
                // Store the post info we care about in the array
                    group: feed,
                    key: feed.title,
                    title: postTitle,
                    author: postAuthor,
                    month: blogPostMonth.toUpperCase(),
                    day: blogPostDay,
                    year: blogPostYear,
                    content: staticContent
        var list = getBlogPosts();
        var groupedItems = list.createGrouped(
            function groupKeySelector(item) { return item.group.key; },
            function groupDataSelector(item) { return item.group; }
        WinJS.Namespace.define("Data", {
            items: groupedItems,
            groups: groupedItems.groups,
            getItemReference: getItemReference,
            getItemsFromGroup: getItemsFromGroup,
            resolveGroupReference: resolveGroupReference,
            resolveItemReference: resolveItemReference
        // Get a reference for an item, using the group key and item title as a
        // unique reference to the item that can be easily serialized.
        function getItemReference(item) {
            return [item.group.key, item.title];
        // This function returns a WinJS.Binding.List containing only the items
        // that belong to the provided group.
        function getItemsFromGroup(group) {
            return list.createFiltered(function (item) { return item.group.key === group.key; });
        // Get the unique group corresponding to the provided group key.
        function resolveGroupReference(key) {
            for (var i = 0; i < groupedItems.groups.length; i++) {
                if (groupedItems.groups.getAt(i).key === key) {
                    return groupedItems.groups.getAt(i);
        // Get a unique item from the provided string array, which should contain a
        // group key and an item title.
        function resolveItemReference(reference) {
            for (var i = 0; i < groupedItems.length; i++) {
                var item = groupedItems.getAt(i);
                if (item.group.key === reference[0] && item.title === reference[1]) {
                    return item;

    Tuesday, May 13, 2014 6:38 PM
  • What do you mean by an XML feed? Can you post a link to an example. As documented, only atom and RSS 2.0 are supported, so if you have something else it isn't expected to work. You would need to write your own handler for that type.
    Tuesday, May 13, 2014 6:54 PM
  • Sorry, that wasn't very clear. All feeds are xml which is why I don't understand the issue between atom and rss. I meant non Atom feeds that end with rss.xml. I can't use links in my posts because I don't have enough points. Like the normal url beginning and then something like "nydailynews/rss.xml" Isn't the code already parsing for any kind of feed? Maybe I need to start with something really simple and get it to not break which has something to do with the textcontent extensions and see if I can figure out what is going on.
    Tuesday, May 13, 2014 9:50 PM
  • Can you post a link to an example?
    Friday, May 23, 2014 3:03 AM
  • I'm not sure if you need to use the .xml file extension. I've seen code using this format:


    Does that URL work in your app?

    If it does, as a quick test, I'd try:

    url: 'http://www.bookreporter.com/reviews/rss',


    url: 'http://www.bookreporter.com/reviews/rss_200',

    Friday, May 23, 2014 10:25 PM