how do i pull down each item in a itemlist for AtomPub data


  • How do i use my current code to loop thru the array, should i use .length() ? or is there a better way. i want to put it in a item list field so i can add more than one item. here is

    my CODE:

    // For an introduction to the Blank template, see the following documentation:
    // http://go.microsoft.com/fwlink/?LinkId=232509
    (function () {
        "use strict";
        var page = WinJS.UI.Pages.define("/default.html", {
            ready: function (element, options) {
                document.getElementById("buttonPrevious").addEventListener("click", previousItemButtonClick, false);
                document.getElementById("buttonNext").addEventListener("click", nextItemButtonClick, false);
            displayCurrentItem = displayCurrentItemGet;
        WinJS.Binding.optimizeBindingReferences = true;
        var app = WinJS.Application;
        var activation = Windows.ApplicationModel.Activation;
        //Stuff for rss
        var client = null;
        var currentFeed = null;
        var currentItemIndex = 0;
        var displayCurrentItem = null;
        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.
        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().
        function getCurrentItem() {
            if (currentFeed) {
                return currentFeed.items[currentItemIndex];
            return null;
        function displayCurrentItemGet() {
        var currentItem = getCurrentItem();
            if (currentItem) {
                var titles = "(no title)";
                var value = "(no value)";
                titles = currentItem.title.text;
                value = currentItem.summary.text;
                document.getElementById("titleField").innerHTML = titles;
                document.getElementById("webView").innerHTML = value;
          // Callback for previousItemButton click event.
        function previousItemButtonClick() {
            if (currentFeed && currentItemIndex > 0) {
        // Callback for nextButton click event.
        function nextItemButtonClick() {
            if (currentFeed && currentItemIndex < currentFeed.items.size - 1) {
        //Error Messaging
        function onError(err) {
        function displayError(message) {
            WinJS.log && WinJS.log(message, "sample", "error");
        function displayStatus(message) {
            WinJS.log && WinJS.log(message, "sample", "status");
    	//pull down feed
        function pullFeed() {
            displayCurrentItem = displayCurrentItemGet;
            var resourceUri;
            try {
                resourceUri = new Windows.Foundation.Uri("http://store.steampowered.com/feeds/newreleases.xml?feed=atom");
            } catch (error) {
                displayError("Error: Invalid URI");
            client = new Windows.Web.AtomPub.AtomPubClient();
            displayStatus("Fetching resource...");
            client.retrieveFeedAsync(resourceUri).done(function (feed) {
                currentFeed = feed;
                //this will set what feed item to set.
                currentItemIndex = 0;
                displayStatus("Fetching resource completed.");
            }, onError);

    Friday, December 14, 2012 1:51 AM


  • Hi Jbostwick,

    In order to display more than one rss feed item, you can consider using the ListView control which support bind to a datasource with multiple items (can be constructed from a javascript array).

    #Adding ListView controls (Windows Store apps using JavaScript and HTML) (Windows)

    Also, I'd recommend you create a javascript based Windows Store app through the "Split App" project template. That project template has pre-generated some page and code which demonstrate how to use ListView and custom HTML elements to show master-details like UI (with multiple items data source).

    #Split project template for Windows Store apps

    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 Thursday, December 20, 2012 10:26 AM
    Monday, December 17, 2012 7:00 AM