NSXMLParser and namespace elements
I am us开发者_开发技巧ing NSXMLParser to parse a Feedburner/atom feed. I can get most elements to work however I am not sure how to parse the following:
I would like to get at and store the href from this tag. How do I do this?
Thanks -Tom Printy
OK I figure it out....
In the idStartElement callback I added the code:
if ( [elementName isEqualToString:@"link"]) {
NSString *string = [attributeDict objectForKey:@"href"];
NSLog(@"Link is %@ ", string);
[currentLink appendString:[self cleanURL:string]]; }
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict {
//NSLog(@"found this element: %@", elementName);
if ( [elementName isEqualToString:@"link"]) {
if([[attributeDict objectForKey:@"rel"] isEqualToString:@"alternate"]){
NSString *string = [attributeDict objectForKey:@"href"];
NSString *titulo = [attributeDict objectForKey:@"title"];
NSLog(@"Link is %@ ", string);
NSLog(@"titulo is %@ ", titulo);
//[currentLink appendString:[self cleanURL:string]];
}
}
if ( [elementName isEqualToString:@"media:thumbnail"]) {
NSString *url = [attributeDict objectForKey:@"url"];
NSLog(@"url is %@ ", url);
}
}
精彩评论