Phonegap RSS feeds, Javascript

前端 未结 5 1740
故里飘歌
故里飘歌 2020-12-15 14:46

I need to write a PhoneGap application (with HTML5 and JS, I don\'t need compatibility with IE) with AJAX so that it reads an RSS feed and looks up some specific information

5条回答
  •  别那么骄傲
    2020-12-15 15:08

    I have just made a phonegap application that parses an external RSS feed using jFeed. I'll give you an example:

    First, I include the following Java scripts in my index.html file:

    
        ...
        
        
        
        
        
        ...
    
    

    Then, in my.js I use the following:

    parseFeed();
    
    function parseFeed() {
    $.getFeed({
        url: 'http://someUrl.com',
        dataType: "xml",
        success: function(feed) {
    
        $('#feedresult').empty();
    
        var html = '
      '; for(var i = 0; i < feed.items.length; i++) { var item = feed.items[i]; html += '
    • ' + '' + item.title + '' + '
    • '; } html = html + '
    '; $('#feedresult').append(html); $('#main').page('destroy').page(); }}); };

    The code then creates a listview (jQuery mobile) in my #feedresult div where each entry represents a feed item. As phonegap utilizes some sort of web view that loads all content using the file:/// protocol ( http://groups.google.com/group/phonegap/browse_thread/thread/b60bda03bac6e9eb ), there is no issue in doing cross domain XMLHttpRequest from phonegap.

提交回复
热议问题