iphone - CDATA Parsing Values -
i parsing cdata gettings values... http://nikelebron.net/feed/
, http://www.nicekicks.com/feed/
in both rss feeds want src value in tag
- (void)parser:(nsxmlparser *)parser foundcdata:(nsdata *)cdatablock { nsstring *somestring = [[nsstring alloc] initwithdata:cdatablock encoding:nsutf8stringencoding]; }
this code print jpg image links in cdata,
-(void) parser:(nsxmlparser *)parser foundcdata:(nsdata *)cdatablock{ nsstring *cdatastring = [[nsstring alloc] initwithdata:cdatablock encoding:nsutf8stringencoding]; nsdatadetector *detect = [[nsdatadetector alloc] initwithtypes:nstextcheckingtypelink error:nil]; nsarray *matches = [detect matchesinstring:cdatastring options:0 range:nsmakerange(0, [cdatastring length])]; for(int i=0; i<matches.count;i++){ nstextcheckingresult *result = [matches objectatindex:i]; nsstring *linkurl = [result url].absolutestring; if([[linkurl pathextension] isequaltostring:@"jpg"]){ //for requirement, change above line //nsstring *pathextension = [linkurl pathextension]; //if((pathextension.length>=3)&&([[pathextension substringtoindex:3] isequaltostring:@"jpg"])){ nslog(@"image link:%@", linkurl); }else nslog(@"link:%@", linkurl); } }
Comments
Post a Comment