title: How to parse two different .xml files at the same time?
body: <p>I am using a tab bar application, and there are 4 different table views. There are four tab bar items and each has a different table view. I should populate arrays form <code>.xml</code> files. Yet, problem is this:</p>
  
  <p>I can parse only one <code>XML</code> file at a time. How can I parse two or more <code>.xml</code> files at the same time by <code>NSXMLParser</code>?</p>
  
  <p>Or should I merge the <code>xml files? Yet, if I merge, I have to create two or more</code>NSMutableArray`s to put those into another tableview views. Any suggestion? </p>
  
  <p>What do you guys suggest? I do not know how to merge those xml files, but even if I do, I should create <code>NSMutableArray</code>s to use those to populate arrays for each view.</p>
  
  <p>Thanks in advance.</p>
  
  <p>Edit:</p>
  
  <p>This is my <code>AppDelegate.m</code></p>
  
  <pre><code>@synthesize window = _window;
  @synthesize tabBarController = _tabBarController;
  
  
  - (void)applicationDidFinishLaunching:(UIApplication *)application {
  
  //Initialize the delegate.
  XMLParser *parser = [[XMLParser alloc] initXMLParser];
  
  // Configure and show the window
  self.window.rootViewController = self.tabBarController;
  [self.window makeKeyAndVisible];
  [window makeKeyAndVisible];
  }
  
  
  - (void)applicationWillTerminate:(UIApplication *)application {
  // Save data if appropriate
  }
  
  
  - (void)dealloc {
  [tabBarController release];
  [window release];
  [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>This is my <code>XMLparser.m</code>:</p>
  
  <pre><code>#import "XMLParser.h"
  #import "XMLAppDelegate.h"
  #import "Duyuru.h"
  #import "Beste.h"
  #import "BesteViewController.h"
  #import "DuyuruViewController.h"
  
  @implementation XMLParser
  
  - (XMLParser *) initXMLParser {
  
  [super init];
  
  appDelegate = (XMLAppDelegate *)[[UIApplication sharedApplication] delegate];
  
  return self;
  }
  
  - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName 
   namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName 
  attributes:(NSDictionary *)attributeDict {
  
  
  if (parser == bestevc.parser ) {
  
      if([elementName isEqualToString:@"Besteler"]) {
      //Initialize the array.
      bestevc.besteler = [[NSMutableArray alloc] init];
      }
  
      else if([elementName isEqualToString:@"Beste"]) {
  
          //Initialize the book.
          aBeste = [[Beste alloc] init];
  
          //Extract the attribute here.
          aBeste.besteID = [[attributeDict objectForKey:@"id"] integerValue];
  
          NSLog(@"Reading id value :%i", aBeste.besteID);
      }
  
   }
  
  if (parser == duyuruvc.parser  ) {
  
      if([elementName isEqualToString:@"Duyurular"]) {
          //Initialize the array.
          duyuruvc.duyurular = [[NSMutableArray alloc] init];
      }
  
      else if([elementName isEqualToString:@"Duyuru"]) {
  
          //Initialize the book.
          aDuyuru = [[Duyuru alloc] init];
  
          //Extract the attribute here.
          aDuyuru.duyuruID = [[attributeDict objectForKey:@"id"] integerValue];
  
          NSLog(@"Reading id value :%i", aDuyuru.duyuruID);
      }
  
    }
  
  }
  
  - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { 
  
   if (parser == bestevc.parser  ) {
      if(!currentElementValue1) 
          currentElementValue1 = [[NSMutableString alloc] initWithString:string];
      else
          [currentElementValue1 appendString:string];
  
      NSLog(@"Processing Value: %@", currentElementValue1);
  }
  
  if (parser == duyuruvc.parser  ) {
      if(!currentElementValue2) 
          currentElementValue2 = [[NSMutableString alloc] initWithString:string];
      else
          [currentElementValue2 appendString:string];
  
      NSLog(@"Processing Value: %@", currentElementValue2);
  }
  }
  
  - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName 
    namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName {
  
     if (parser == bestevc.parser) {
  
      if([elementName isEqualToString:@"Besteler"])
      return;
      //There is nothing to do if we encounter the Books element here.
  
      // and release the object.
      if([elementName isEqualToString:@"Beste"]) {
          [bestevc.besteler addObject:aBeste];
  
          [aBeste release];
          aBeste = nil;
      }
      else 
          [aDuyuru setValue:currentElementValue1 forKey:elementName];
  
      [currentElementValue1 release];
      currentElementValue1 = nil;
  }
  if (parser == duyuruvc.parser) {
  
      if([elementName isEqualToString:@"Duyurular"])
          return;
      //There is nothing to do if we encounter the Books element here.
  
      // and release the object.
      if([elementName isEqualToString:@"Duyuru"]) {
          [duyuruvc.duyurular addObject:aDuyuru];
  
          [aDuyuru release];
          aDuyuru = nil;
      }
      else 
          [aDuyuru setValue:currentElementValue2 forKey:elementName];
  
      [currentElementValue2 release];
      currentElementValue2 = nil;
  }
  
  }
  
  
  - (void) dealloc {
  [aDuyuru release];
  [aBeste release];
  [currentElementValue1 release];
  [currentElementValue2 release];
  [super dealloc];
  }
  
  @end
  </code></pre>
  
  <p>This is my <code>BesteViewController.m</code>:</p>
  
  <pre><code>#import "BesteViewController.h"
  #import "XMLAppDelegate.h"
  #import "Beste.h"
  #import "XMLParser.h"
  
  @implementation BesteViewController
   @synthesize parser, besteler;
  
  
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
  return 1;
  }
  
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)
   section   {
    return [besteler count];
   }
  
  
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath
   (NSIndexPath *)indexPath {
  
  static NSString *CellIdentifier = @"Cell";
  
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if (cell == nil) {
      cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero
    reuseIdentifier:CellIdentifier] autorelease];
   }
  
  Beste *aBeste = [besteler objectAtIndex:indexPath.row];
  
  [[cell textLabel] setText:aBeste.name];
  cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
  
  // Set up the cell
  return cell;
  }
  
  - (void)viewDidLoad {
  [super viewDidLoad];
  // Uncomment the following line to add the Edit button to the navigation bar.
  // self.navigationItem.rightBarButtonItem = self.editButtonItem;
  
  appDelegate = (XMLAppDelegate *)[[UIApplication sharedApplication] delegate];
  
  NSURL *url = [[NSURL alloc] 
        initWithString:@"https://sites.google.com/site/bfbremoteser
     ver/iphoneapp/besteler.xml"];
  NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
  
  
  //Initialize the delegate.
  XMLParser *parser = [[XMLParser alloc] initXMLParser];
  
  
  //Set delegate
  [xmlParser setDelegate:parser];
  
  
  //Start parsing the XML file.
  BOOL success = [xmlParser parse];
  
  if(success)
      NSLog(@"No Errors");
  else
      NSLog(@"Error Error Error!!!");
  
  self.navigationItem.title = @"Besteler";
   }
  
  
  
  
  
  
  
  /*
  // Override to support rearranging the list
  - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath   
  
   *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
  }
  */
  
  
  /*
   // Override to support conditional rearranging of the list
  - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath*)
  indexPath {
  // Return NO if you do not want the item to be re-orderable.
  return YES;
  }
  */
  
  /*
  - (void)viewWillAppear:(BOOL)animated {
  [super viewWillAppear:animated];
  }
  */
  /*
  - (void)viewDidAppear:(BOOL)animated {
  [super viewDidAppear:animated];
  }
    */
  /*
  - (void)viewWillDisappear:(BOOL)animated {
  }
  */
  /*
  - (void)viewDidDisappear:(BOOL)animated {
  }
  */
  
  
  
  
  - (void)didReceiveMemoryWarning {
  [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
  // Release anything that's not essential, such as cached data
  }
  
  
  - (void)dealloc {
  [besteler release];
  [appDelegate release];
  [super dealloc];
  }
  
  
  @end
  </code></pre>