Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

XML RSS

Hi,
How can I use RSS Feed here? How to parse XML RSS in Anroid? Please suggest me.

— asked September 27th 2010 by somnath banik
  • android
0 Comments

3 Answers

  • KitchenSink has some mighty fine examples on RSS Feeds.

    — answered September 28th 2010 by Simon Kok
    permalink
    0 Comments
  • KitchenSink has some mighty fine examples on RSS Feeds.

    — answered September 28th 2010 by Simon Kok
    permalink
    2 Comments
    • yes I see that, but if I try to use some other xml rss like http://feeds.nytimes.com/nyt/rss/Africa it doesn't work. Please suggest me.

      — commented September 28th 2010 by somnath banik
    • Review the sample code here:

      http://developer.appcelerator.com/question/64791/xml-rss-feed-kitchensink-issue

      Now, the best thing is to look at the XML structure - use FireFox with the REST Client - it formats the XML nice and pretty to see.

      Good luck!

      — commented September 30th 2010 by Simon Kok
  • A way is to use a converter xml2json like XMLtools.js from David Bankier. Htttp client retrieves you the xml and the lib converts to object.
    Here an example, how to use

    exports.getLatest = function(_callback) {
        require('offlinealert').create();
        var xhr = Ti.Network.createHTTPClient({
            timeout : 16000,
            onload : function() {
                var XMLTools = require('modules/XMLtools');
                var parser = new XMLTools(this.responseXML);
                var rss = parser.toObject();
                _callback((Object.prototype.toString.call(rss.channel.item) === '[object Array]' ) ? rss.channel.item : [rss.channel.item]);
            },
            onerror : function(e) {
                console.log(e.error);
            }
        });
        xhr.open('GET', 'http://www.podcampus.de/nodes.rss');
        xhr.send();
    }
    
    — answered February 17th 2013 by Rainer Schleevoigt
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.