Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

1458279

Suspended
Original poster
I've been digging into an RSS news feed reader. I'm running into a problem when I change from one feed to another.

The tutorial:
http://www.touch-code-magazine.com/tutorial-building-advanced-rss-reader-with-ios6/

I wanted to do things like read different feeds and be able to add new ones as needed. I'm new to XML and it seems I'm having a problem with different data structures being returned.

Is there a universal routine to read different news feeds or do you have to know the structure in advance?

Is there a getStructureFromXML() function somewhere, so I can at least get an idea of the structure that's coming in?

Or maybe a routine that will make an array and load it in whatever the structure is?


BTW, theres a weak spot in the tutorial code:

Code:
NSString* itemDescription = [NSString stringWithFormat:@"%@...", [self.itemDescription substringToIndex:100]];

Will crash if the string is < 100, this will fix it:

Code:
   NSString* itemDescription = @"*Error* Description Too short...";

    if (self.itemDescription.length > 20)

    {

        itemDescription = [NSStringstringWithFormat:@"%@...", [self.itemDescriptionsubstringToIndex:MIN(100,self.itemDescription.length-1)]];

    }
 
In my limited experience with XML (I wrote a podcast app, podcasts feeds are just RSS Feeds), the submitters needed to conform to a structure. I'm not sure if it's the same in all cases but I assume there is an agreed upon way on setting up an RSS Feed so it can be easily read by multiple RSS programs. I would spit your XML you returned into the log and adjust your model to what is returned. I would be 9/10 times most feeds are similar.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.