Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import "XMLParser.h"
- @implementation XMLParser
- @synthesize thePresentation,theSlide,presentations;
- -(id)initXMLParser{
- if(self == [super init]) {
- app = (AppDelegate *)[[UIApplication sharedApplication]delegate];
- }
- return self;
- }
- -(void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
- if ([elementName isEqualToString:@"presentation"]) {
- NSLog(@"user element found – create a new instance of User class...");
- app.presentationArray = [[NSMutableArray alloc] init];
- thePresentation = [[Presentation alloc] init];
- thePresentation.pIdentifier = [attributeDict objectForKey:@"identifier"];
- thePresentation.pLabel = [attributeDict objectForKey:@"label"];
- NSLog(@"PLabel: %@", thePresentation.pLabel);
- NSLog(@"PNAME: %@", thePresentation.pIdentifier);
- }else if ([elementName isEqualToString:@"slides"]) {
- NSLog(@"Slides");
- thePresentation.slides = [NSMutableArray array];
- }else if ([elementName isEqualToString:@"slide"]) {
- NSLog(@"slide");
- theSlide = [[Slide alloc] init];
- theSlide.index = [[attributeDict objectForKey:@"index"] integerValue];
- NSLog(@"index :%i", theSlide.index);
- theSlide.sLabel = [attributeDict objectForKey:@"label"];
- NSLog(@"sLabel: %@", theSlide.sLabel);
- theSlide.identifier = [attributeDict objectForKey:@"identifier"];
- NSLog(@"identifier: %@", theSlide.identifier);
- [thePresentation.slides addObject:theSlide];
- NSLog(@"thePresentation is: %@", thePresentation.slides);
- NSLog(@"theSlide is: %@", theSlide);
- }
- }
- -(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
- if(!currentElementValue){
- currentElementValue = [[NSMutableString alloc] initWithString:string];
- }else
- [currentElementValue appendString:string];
- NSLog(@"Processing Value: %@", currentElementValue);
- }
- -(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
- if([elementName isEqualToString:@"presentation"]){
- [app.presentationArray addObject:thePresentation];
- thePresentation = nil;
- }
- }
- @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement