.h #import @interface samplexmlViewController : UIViewController{ NSMutableArray *array1; NSMutableDictionary *dict1,*tempDict; NSString *xmlString; IBOutlet UILabel *lbl1,*lbl2,*lbl3; int i,counts,table; } -(void)showQ:(NSMutableDictionary *)dicts; @end .m – (void)viewDidLoad { NSURL *url = [[NSURL alloc] initWithString:@"url"]; NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url]; //Initialize the delegate. //Set delegate [xmlParser setDelegate:self]; //Start parsing the XML file. BOOL success = [xmlParser parse]; if(success) NSLog(@"No Errors"); else NSLog(@"Error Error Error!!!"); tempDict=[[NSMutableDictionary alloc]init ]; tempDict=[array1 objectAtIndex:i]; [self showQ:tempDict]; [super viewDidLoad]; } – (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { if ([elementName isEqualToString:@"parentnode"]) { array1=[[NSMutableArray alloc]init ]; } if ([elementName isEqualToString:@"child"]) { dict1=[[NSMutableDictionary alloc]init]; } } – (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if ([elementName isEqualToString:@"subchild1″]) { [dict1 setObject:xmlString forKey:@"subchild1″]; } if ([elementName isEqualToString:@"subchild2″]) { [dict1 setObject:xmlString forKey:@"subchild2″]; } if ([elementName isEqualToString:@"subchild3″]) { [dict1 setObject:xmlString forKey:@"subchild3″]; } if ([elementName isEqualToString:@"child"]) { [array1 addObject:dict1]; NSLog(@"array 1 is %@",array1); } if ([elementName isEqualToString:@"parent"]) { NSLog(@"total array is %@",array1); } xmlString=nil; } -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if(xmlString == nil) xmlString = [[NSMutableString alloc] initWithString:string]; else [xmlString appendString:string]; } -(void)showQ:(NSMutableDictionary *)dicts { lbl1.
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
Iphone
Iphone
0 Comments