locked
rss reader html5 issues

    Question

  • Followed the RSS in 30mins by David Rousset, Windows 8 HTML5 Metro Style App: RSS reader in 30min - building your WordPress or Community Server version

    but i am having issues with a non blog rss,   i get error "0x800a138f - JavaScript runtime error: Unable to get property 'querySelectorAll' of undefined or null reference"   works fine with the default rss atom..

    this is the line it complains about.

    var items = 
    rss.responseXML.querySelectorAll("item");

    this is the feed i am trying to pull from.  http://store.steampowered.com/feeds/newreleases.xml

    How can i see what WinJS.xhr is pulling down. perhaps since it ends in .xml its having an issue grabbing the data.

    Thanks hope i can solve this soon

    Wednesday, December 12, 2012 7:14 AM

Answers

  • Hi,

    Please refer to the example as follow:

        var feedItems = [];
    
    
        function generateSampleData() {
            var items = new Array();
            WinJS.xhr({ url: 'http://blogs.msdn.com/b/windowsstore/rss.aspx' }).done(function (result) {
                var xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
                xmlDoc.loadXml(result.responseText);
    
                var nodes = xmlDoc.selectNodes("//item");
                
                nodes.forEach(function (val, idx, travObj) {
    
                    var title = val.selectSingleNode("title").innerText;
                    var description = val.selectSingleNode("description").innerText;
                    var link = val.selectSingleNode("link").innerText;
    
                    var newItem = {
                        title: title,
                        summary: description,
                        uri: link
                    };
    
                    items.push(newItem);
                });
                //DataUtils.feedItems = items;
                feedItems = items;
    
            });
           
    
            console.log(DataUtils.feedItems);
                // Each of these sample groups must have a unique key to be displayed
                // separately.
                var sampleItems = items;       
    
            // return sampleItems;
                return feedItems;
            
            }
        WinJS.Namespace.define(
    "DataUtils", {
        feedItems: feedItems
    }
        );
        winjs.xhr call xml file
    


    Roy
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Song Tian Tuesday, December 18, 2012 8:13 AM
    Wednesday, December 12, 2012 11:26 AM

All replies

  • Hi,

    Please refer to the example as follow:

        var feedItems = [];
    
    
        function generateSampleData() {
            var items = new Array();
            WinJS.xhr({ url: 'http://blogs.msdn.com/b/windowsstore/rss.aspx' }).done(function (result) {
                var xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
                xmlDoc.loadXml(result.responseText);
    
                var nodes = xmlDoc.selectNodes("//item");
                
                nodes.forEach(function (val, idx, travObj) {
    
                    var title = val.selectSingleNode("title").innerText;
                    var description = val.selectSingleNode("description").innerText;
                    var link = val.selectSingleNode("link").innerText;
    
                    var newItem = {
                        title: title,
                        summary: description,
                        uri: link
                    };
    
                    items.push(newItem);
                });
                //DataUtils.feedItems = items;
                feedItems = items;
    
            });
           
    
            console.log(DataUtils.feedItems);
                // Each of these sample groups must have a unique key to be displayed
                // separately.
                var sampleItems = items;       
    
            // return sampleItems;
                return feedItems;
            
            }
        WinJS.Namespace.define(
    "DataUtils", {
        feedItems: feedItems
    }
        );
        winjs.xhr call xml file
    


    Roy
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Song Tian Tuesday, December 18, 2012 8:13 AM
    Wednesday, December 12, 2012 11:26 AM
  • Well i tried to work with your code, but I must be unsure how to implement it, as when i run it, dies on me, without telling me whats wrong with my code. I am new to working with javascript debugging so. I haven't a clue whats wrong here.

    so here is my whole default.js

    // For an introduction to the Blank template, see the following documentation:
    // http://go.microsoft.com/fwlink/?LinkId=232509
    (function () {
        "use strict";
    
        WinJS.Binding.optimizeBindingReferences = true;
    
        var app = WinJS.Application;
        var activation = Windows.ApplicationModel.Activation;
        // var articlesList;
        var feedItems = [];
    
        app.onactivated = function (args) {
            if (args.detail.kind === activation.ActivationKind.launch) {
                if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
                    // TODO: This application has been newly launched. Initialize
                    // your application here.
                } else {
                    // TODO: This application has been reactivated from suspension.
                    // Restore application state here.
                }
    
                args.setPromise(WinJS.UI.processAll().then(generateSampleData));
            }
        };
    
        function generateSampleData() {
            var items = new Array();
            WinJS.xhr({ url: 'http://blogs.msdn.com/b/windowsstore/rss.aspx' }).done(function (result) {
                var xmlDoc = new Windows.Data.Xml.Dom.XmlDocument();
                xmlDoc.loadXml(result.responseText);
    
                var nodes = xmlDoc.selectNodes("//item");
    
                nodes.forEach(function (val, idx, travObj) {
    
                    var title = val.selectSingleNode("title").innerText;
                    var description = val.selectSingleNode("description").innerText;
                    var link = val.selectSingleNode("link").innerText;
    
                    var newItem = {
                        title: title,
                        summary: description,
                        uri: link
                    };
    
                    items.push(newItem);
                });
                //DataUtils.feedItems = items;
                feedItems = items;
    
            });
    
    
            console.log(DataUtils.feedItems);
            // Each of these sample groups must have a unique key to be displayed
            // separately.
            var sampleItems = items;
    
            // return sampleItems;
            return feedItems;
    
        }
        WinJS.Namespace.define("DataUtils", {
        feedItems: feedItems }
        );
    
    
    
        app.oncheckpoint = function (args) {
            // TODO: This application is about to be suspended. Save any state
            // that needs to persist across suspensions here. You might use the
            // WinJS.Application.sessionState object, which is automatically
            // saved and restored across suspension. If you need to complete an
            // asynchronous operation before your application is suspended, call
            // args.setPromise().
        };
    
        app.start();
    })();

    ran it again, and found

    Exception was thrown at line 5840, column 33 in ms-appx://microsoft.winjs.1.0/js/base.js
    0x800a138f - JavaScript runtime error: Unable to get property 'ItemList' of undefined or null reference
    The program '[6324] WWAHost.exe' has exited with code -1 (0xffffffff).




    • Edited by Jbostwick Thursday, December 13, 2012 3:22 AM
    Thursday, December 13, 2012 3:08 AM
  • Hi,

    Then I suggest you familiar with winjs.xhr first.

    #WinJS.xhr function (Windows)

    http://msdn.microsoft.com/en-us/library/windows/apps/br229787.aspx


    Roy
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, December 13, 2012 3:13 AM
  • So if i understand correctly. the error i am getting is that of the WinJS.xhr function

    WinJS.xhr({ url: 'http://blogs.msdn.com/b/windowsstore/rss.aspx' }).done(function (result)

    the part where is have .done(function MISSING (result)

    there is a MISSING Function name here?  that or I am just clueless. and guessing. I do know this, that I don't fully get promises or async all that much. nor html requesting. i just know core javascript language.   i saw some useful info at the link on the xhr page:  http://msdn.microsoft.com/en-us/library/windows/apps/hh868282.aspx   maybe that would help me out.

    Thursday, December 13, 2012 7:26 AM