2010-02-04 83 views
0

我正在使用NSXMLParser來解析Feedburner/atom feed。我能得到大多數元素然而工作我不知道如何解析如下:NSXMLParser和命名空間元素

我想獲得在和HREF從這個標籤存儲。我該怎麼做呢?

感謝 -Tom Printy

+0

你可能需要正確格式化XML/URL你想在你的OP包括,因爲它的現身空白/缺失。 – 2010-02-04 04:22:49

回答

0

OK我看着辦吧....

在idStartElement回調我添加的代碼:

如果([的ElementName isEqualToString:@「鏈接「]){
NSString * string = [attributeDict objectForKey:@」href「];
NSLog(@「Link is%@」,string);
[currentLink appendString:[self cleanURL:string]]; }

0
- (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); 
    } 

} 
+1

這可以使用一些格式和解釋。 – Yuck 2012-11-16 00:22:01

相關問題