XML to JSON conversion for JavaScript Windows 8 Metro Apps

I came by this snippet from this site: http://ryanlowdermilk.com/2012/04/increase-performance-of-metro-apps-by-46-with-2-lines-of-code/ and it blew my mind.  You can convert an XML response to a JSON object   That’s pretty sweet.  Thanks @RYANLOWDERMILK !

 

function loadNews() {

    var dataControl = document.getElementById(“myListView”).winControl,
        feedburnerUrl = “http://feeds.feedburner.com/WindowsPhoneDevPodcast”,
        feedUrl = “http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&output=json&num=999&q=”
                  + encodeURIComponent(feedburnerUrl);
    WinJS.xhr({ url: feedUrl })
        .done(function complete(result) {
            var jsonData = JSON.parse(result.response);
            var list = new WinJS.Binding.List(jsonData.responseData.feed.entries);
            dataControl.itemDataSource = list.dataSource;
        });
}

One thought on “XML to JSON conversion for JavaScript Windows 8 Metro Apps

Leave a Reply

Your email address will not be published. Required fields are marked *