このコードは、CDATA 内のすべてのjpg 画像リンクを出力します。
-(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 your requirement, change the above line to
//NSString *pathExtension = [linkUrl pathExtension];
//if((pathExtension.length>=3)&&([[pathExtension substringToIndex:3] isEqualToString:@"jpg"])){
NSLog(@"image link:%@", linkUrl);
}else NSLog(@"link:%@", linkUrl);
}
}