You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am able to Fetch data like Title and Description or etc with
Object for key @"Ttile" and Object for key "@PUBDATE"
But in Terms of Image all RSS Feed using Different Key for image Like Object for key @"image" , Object for key @"src" , Object for key @"Media:content"
I am able to fetch few of the Image with Objectforkey:@"media:content"
but other link uses different Objectforkey like @"image" or @"Media:thumbline".
How can i fetch it this different key or how can i set it in single tableview?
Here is my code from which i am able to fetch image with objectforkey:@"Media:content" but i can't understand how to set other keys for image.
//MWFeeditem.h
#import <Foundation/Foundation.h>
@interface MWFeedItem : NSObject <NSCoding> {
NSString *identifier; // Item identifier
NSString *title; // Item title
NSString *link; // Item URL
NSDate *date; // Date the item was published
NSDate *updated; // Date the item was updated if available
NSString *summary; // Description of item
NSString *content; // More detailed content (if available)
NSString *author; // Item author
NSString *image; // image for the feed
// Enclosures: Holds 1 or more item enclosures (i.e. podcasts, mp3. pdf, etc)
// - NSArray of NSDictionaries with the following keys:
// url: where the enclosure is located (NSString)
// length: how big it is in bytes (NSNumber)
// type: what its type is, a standard MIME type (NSString)
NSArray *enclosures;
}
@property (nonatomic, copy) NSString *identifier;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *link;
@property (nonatomic, copy) NSDate *date;
@property (nonatomic, copy) NSDate *updated;
@property (nonatomic, copy) NSString *summary;
@property (nonatomic, copy) NSString *content;
@property (nonatomic, copy) NSString *author;
@property (nonatomic, copy) NSArray *enclosures;
@property (nonatomic, copy) NSString *image;
@end
// MWFeeditem.m
#pragma mark NSCoding
- (id)initWithCoder:(NSCoder *)decoder {
if ((self = [super init])) {
identifier = [decoder decodeObjectForKey:@"identifier"];
title = [decoder decodeObjectForKey:@"title"];
link = [decoder decodeObjectForKey:@"link"];
date = [decoder decodeObjectForKey:@"date"];
updated = [decoder decodeObjectForKey:@"updated"];
summary = [decoder decodeObjectForKey:@"summary"];
content = [decoder decodeObjectForKey:@"content"];
author = [decoder decodeObjectForKey:@"author"];
enclosures = [decoder decodeObjectForKey:@"enclosures"];
image = [decoder decodeObjectForKey:@"media:content"];
}
return self;
}
- (void)encodeWithCoder:(NSCoder *)encoder {
if (identifier) [encoder encodeObject:identifier forKey:@"identifier"];
if (title) [encoder encodeObject:title forKey:@"title"];
if (link) [encoder encodeObject:link forKey:@"link"];
if (date) [encoder encodeObject:date forKey:@"date"];
if (updated) [encoder encodeObject:updated forKey:@"updated"];
if (summary) [encoder encodeObject:summary forKey:@"summary"];
if (content) [encoder encodeObject:content forKey:@"content"];
if (author) [encoder encodeObject:author forKey:@"author"];
if (enclosures) [encoder encodeObject:enclosures forKey:@"enclosures"];
if (image) [encoder encodeObject:image forKey:@"media:content"];
}
@end
// MWFwwsparser.m
- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
MWXMLLog(@"NSXMLParser: didEndElement: %@", qName);
@autoreleasepool {
// Parse content as structure (Atom feeds with element type="xhtml")
// - Use elementName not qualifiedName to ignore XML namespaces for XHTML entities
if (parseStructureAsContent) {
// Check for finishing parsing structure as content
if (currentPath.length > pathOfElementWithXHTMLType.length) {
// Close XHTML tag unless it is an empty element
if (!ELEMENT_IS_EMPTY(elementName)) [currentText appendFormat:@"</%@>", elementName];
// Adjust path & don't continue
self.currentPath = [currentPath stringByDeletingLastPathComponent];
// Return
return;
}
// Finish
parseStructureAsContent = NO;
self.pathOfElementWithXHTMLType = nil;
// Continue...
}
// Store data
BOOL processed = NO;
if (currentText) {
// Remove newlines and whitespace from currentText
NSString *processedText = [currentText stringByRemovingNewLinesAndWhitespace];
// Process
switch (feedType) {
case FeedTypeRSS: {
// Specifications
// http://cyber.law.harvard.edu/rss/index.html
// http://web.resource.org/rss/1.0/modules/dc/ Dublin core also seems to be used for RSS 2 as well
// Item
if (!processed) {
if ([currentPath isEqualToString:@"/rss/channel/item/title"]) { if (processedText.length > 0) item.title = processedText; processed = YES; }
else if ([currentPath isEqualToString:@"/rss/channel/item/link"]) { if (processedText.length > 0) item.link = processedText; processed = YES; }
else if ([currentPath isEqualToString:@"/rss/channel/item/author"]) { if (processedText.length > 0) item.author = processedText; processed = YES; }
else if ([currentPath isEqualToString:@"/rss/channel/item/dc:creator"]) { if (processedText.length > 0) item.author = processedText; processed = YES; }
else if ([currentPath isEqualToString:@"/rss/channel/item/guid"]) { if (processedText.length > 0) item.identifier = processedText; processed = YES; }
else if ([currentPath isEqualToString:@"/rss/channel/item/description"]) { if (processedText.length > 0) item.summary = processedText; processed = YES; }
else if ([currentPath isEqualToString:@"/rss/channel/item/content:encoded"]) { if (processedText.length > 0) item.content = processedText; processed = YES; }
else if ([currentPath isEqualToString:@"/rss/channel/item/pubDate"]) { if (processedText.length > 0) item.date = [NSDate dateFromInternetDateTimeString:processedText formatHint:DateFormatHintRFC822]; processed = YES; }
else if ([currentPath isEqualToString:@"/rss/channel/item/enclosure"]) { [self createEnclosureFromAttributes:currentElementAttributes andAddToItem:item]; processed = YES; }
else if ([currentPath isEqualToString:@"/rss/channel/item/dc:date"]) { if (processedText.length > 0) item.date = [NSDate dateFromInternetDateTimeString:processedText formatHint:DateFormatHintRFC3339]; processed = YES; }
***// Changes Done here for image //***
else if ([currentPath isEqualToString:@"/rss/channel/item/media:content"])
{
if ([self.currentElementAttributes objectForKey:@"url"])
item.image = self.currentElementAttributes[@"url"];
processed = YES; }
}
and here is my UITableview Method where i have to set image in cell.
I am working on RSSFeed project. i want to fetch data from five different url's XML.
http://rss.news.yahoo.com/rss/world - Yahoo.com
http://news.google.com/news?pz=1&ned=us&hl=en&topic=w&output=rss - Google.com
http://rssfeeds.usatoday.com/UsatodaycomWorld-TopStories - USA Today
I am able to Fetch data like Title and Description or etc with
Object for key @"Ttile"
andObject for key "@PUBDATE"
But in Terms of Image all RSS Feed using Different Key for image Like
Object for key @"image"
,Object for key @"src"
,Object for key @"Media:content"
I am able to fetch few of the Image with
Objectforkey:@"media:content"
but other link uses different Objectforkey like @"image" or @"Media:thumbline".
How can i fetch it this different key or how can i set it in single tableview?
I am Using MWFeedParser for XML Parsing.
Here is my code from which i am able to fetch image with
objectforkey:@"Media:content"
but i can't understand how to set other keys for image.// MWFeeditem.m
// MWFwwsparser.m
and here is my UITableview Method where i have to set image in cell.
For More Reference Here i have Attached Pastie.org link with full code.
MWFeed parsers's class file with changes
MWFeedItem.h
MWFeedItem.m
MWFeedParser.h
MWFeedParser.m
Application's class file .
MainViewController.h
MainViewController.m
The text was updated successfully, but these errors were encountered: