NSXMLParser delegate drops NSArray

silar001

New Member
I am currently trying to save two NSDictionaries into a NSMutableArray twice however as the thread progresses through the notes in NSXMLParser it only ever stores the last itteration of values.. which means the values before that are lost and I cannot figure out why.this is what my NSXMLparser looks like.\[code\]- (void)startTheParsingProcess:(NSData *)parserData{ NSXMLParser *parser = [[NSXMLParser alloc] initWithData:parserData]; //parserData passed to NSXMLParser delegate which starts the parsing process [parser setDelegate:self]; [parser parse]; // starts the event-driven parsing operation.}- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{ if ([elementName isEqualToString:@"Axis"]) { parsedAxisMutableDictionary = [[NSMutableDictionary alloc] initWithDictionary:attributeDict]; } if ([elementName isEqualToString:@"Macs"]) { parsedMacsMutableDictionary = [[NSMutableDictionary alloc] initWithDictionary:attributeDict]; } if ([elementName isEqualToString:@"Axes"]) { self.parsedDataArrayOfDictionaries = [NSMutableArray arrayWithCapacity:8]; }}- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{ if ([elementName isEqualToString:@"Axis"]) { [parsedDataArrayOfDictionaries addObject:parsedAxisMutableDictionary]; [parsedDataArrayOfDictionaries addObject:parsedMacsMutableDictionary]; }}//etc\[/code\]So the thread steps through the "startTheParsingProcess" the first element it hits is Axes, this sets up the array then it dose Axis and Macs, from there it goes into the "didEndElement" method and i store the two dictionaries into my array, the thread goes back into "startTheParsingProcess" it enters Axis and Macs then when it goes back to "didEndElement" the parsedDataArrayOfDictionaries is completely empty..the xml looks like\[code\]<Axes> // i should say there can be many Axis/Macs in this one Axes element.. <Axis element1="1" element2="2"> </Macs"> </Axis></Axes>\[/code\]also parsedDataArrayOfDictionaries is declared in the header file and then @synthesized\[code\]NSMutableArray *parsedDataArrayOfDictionaries;//..@property (strong, nonatomic) NSMutableArray *parsedDataArrayOfDictionaries;\[/code\]any help would be appreciated.
 
Back
Top