how to parse rss xml?
i am using below url for rss parsing. http://news.baidu.com/n?cmd=4&class=finannews&tn=rss
But it gives error code 31.Is it possible parsing this type of rss. If yes then plese give me idea about that.
I am using below code.
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSURL *xmlURL = [NSURL URLWithString:URL];
[xmlParser setClassName:className withRootName:roo开发者_如何学CtName];
[xmlParser setDelegate:xmlParser];
[xmlParser setShouldProcessNamespaces:NO];
[xmlParser setShouldReportNamespacePrefixes:NO];
[xmlParser setShouldResolveExternalEntities:NO];
[xmlParser parse];
[m_delegate setData:xmlParser.message items:xmlParser.items];
//[xmlParser release];
[pool release];
since the feed is in Chinese the characters recognized are in some type of codes.
Try decoding those codes and feed will be parsed correspondingly
Use google-data-api for parsing of feeds like this. it will give you the relevant information in the form categorised data-structure. For your help I am posting some of the code that might give you some hint.
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSURL *feedURL = [[NSURL alloc] initWithString:url];
NSData *data = [NSData dataWithContentsOfURL:feedURL];
GDataFeedBase *feedBase = [[GDataFeedBase alloc] initWithData:data];
NSArray *linksArr = [feedBase links];
if(feedArray == nil){
[self setFeedArray:[NSMutableArray array]];
}
[feedArray addObjectsFromArray:[feedBase entries]];
[feedBase release];
[feedURL release];
[pool release];
Now in the feed array you will have the relevant information.
Hope this helps.
Thanks,
Madhup
精彩评论