Newsletters RSS Feeds, Javascript

I need to write a PhoneGap application (with HTML5 and JS, I do not need IE compatibility) with AJAX so that it reads the RSS feed and looks at it with some specific information. The problem I am facing is that I have a better way to make an RSS feed and jQuery cannot execute XML. Any suggestions?

+3
javascript jquery html5 cordova
Jun 26 '11 at 12:12
source share
5 answers
+5
Jun 26 '11 at 12:21
source share

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

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

<head> ... <script type="text/javascript" src="phonegap-1.0.0.js"></script> <script type="text/javascript" src="jquery/jquery-1.6.4.js"></script> <script type="text/javascript" src="jquery.mobile/jquery.mobile-1.0b3.min.js"></script> <script type="text/javascript" src="jquery.jfeed/dist/jquery.jfeed.js"></script> <script type="text/javascript" src="scripts/my.js"></script> ... </head> 

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 = '<ul data-role="listview">'; for(var i = 0; i < feed.items.length; i++) { var item = feed.items[i]; html += '<li>' + '<a href="#article?id=' + i + '">' + item.title + '</a>' + '</li>'; } html = html + '</ul>'; $('#feedresult').append(html); $('#main').page('destroy').page(); }}); }; 

The code then creates a list (jQuery mobile) in my #feedresult div, where each entry represents a feed item. Since the telephone delay uses some kind of web browsing, which downloads all the content using the file: /// protocol ( http://groups.google.com/group/phonegap/browse_thread/thread/b60bda03bac6e9eb ), in cross domain execution XMLHttpRequest from the phone saver.

+4
Sep 25 '11 at 20:26
source share

This question is old, but may be useful for resolving it in 2014. -).

I am testing a lot of jQuery plugins to enable RSS reader, but this only work like charme in 1mn, zrssfeed

Just add a call (after calling jquery and jquery mobile) in the header:

 <script type="text/javascript" src="jquery.zrssfeed.min.js"></script> 

And after running jquery, call like this:

 <script type="text/javascript"> $(document).ready(function () { $('#feedresult').rssfeed('http://my.wordpress.website.com/feed/', { limit: 5 }); }); </script> 

I hope this help, Mike

+2
Feb 13 '14 at 22:44
source share

What do you mean, jQuery cannot execute XML. jQuery is JavaScript, and jQuery uses XMLHttpRequest when making Ajax calls. See XML* Name XML* . See: http://api.jquery.com/jQuery.ajax/ . There is a parameter dataType param. You can pass it xml . After that, you will get a dom object with all the methods of the dom object.

You can use it as a second parameter for jQuery selectors:

 jQuery.get(url, {}, function (data) { var entries = $("entry", data); doSomething(entries); }, 'xml'); 
+1
Jun 26 '11 at 12:56 on
source share

One option is to use the RSS-to-JSON feed, for example, here: http://pipes.yahoo.com/pipes/pipe.info?_id=2FV68p9G3BGVbc7IdLq02Q

0
Jun 26 '11 at 12:14
source share



All Articles