views:

35

answers:

1

Hello all I'm using NSXMLParser to parse some xml data. I'm using this data to build a Tree representation to create a hierarchy for a drilldowntable.

- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName 
  namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName 
 attributes:(NSDictionary *)attributeDict {

 if([elementName isEqualToString:@"exercises"]) {
   //init tree 
  appDelegate.Tree = [NSMutableDictionary new];
  appDelegate.Rows = [NSMutableArray new];
  [appDelegate.Tree setObject:appDelegate.Rows forKey:@"Rows"];
   ...

Now if the element menuitem in my xml is being read then it will initialize and add theChildren to the menu_item dictionary

if([elementName isEqualToString:@"menuitem"]) {


  appDelegate.theChildren = [NSMutableArray new];
  [appDelegate.menu_item setObject:appDelegate.theChildren forKey:@"Children"];

This is all going according to plan.

However the following is not going the way I want it to go. When I see another tag (workout_mob) I want theChildren to be filled and this only happens with the bottom dictionary item.

http://img188.imageshack.us/img188/7052/picture4efx.png

if([elementName isEqualToString:@"workout_mob"]) {

  appDelegate.work_out_mob = [NSMutableDictionary new];


  [appDelegate.theChildren addObject:appDelegate.work_out_mob];

Does anyone have a clue as to why it isn't at least filling both my items I mean it's adding the Children array to the both of them so why just the bottom one for the rest. If I add another xmlline in my xml code like so:

<menu_mob>
   <menuitem id="1" text="Press this for exercises" pic="workout" />
   <menuitem id="2" text="VirtuaGym online" pic="online" />
                    *<menuitem id="3" text="the Added Line" pic="online" />*
 </menu_mob>

then it will add all the Children items to the bottom menuitem ( imagine another dictionary item (3)). So why ?

A: 

MMm it seems I was resetting my array ;) so problem solved.

jovany