title: How to parse Multiple .xml files in iphone?
body: <p>Its my first experience with xmls so please don't be harsh on me if my question is low quality. I am working on app where I retrieve all data using xml files from server.</p>
  
  <p>Before posting question here I read some <a href="https://stackoverflow.com/questions/11323326/xml-parsing-in-ios-tutorial">Tutorials</a> about xml file parsing.  But when I start to implement it in my app, then I am totally confused at the point when I am trying to parse the second Xml file and so on.</p>
  
  <p>Now I want to explain my app flow using some screenshot so that it become easy for everyone that what I want.</p>
  
  <ol>
  <li><a href="http://tinypic.com/view.php?pic=280qq36&amp;s=6" rel="nofollow noreferrer">First view </a></li>
  <li><a href="http://tinypic.com/view.php?pic=9u3v9y&amp;s=6" rel="nofollow noreferrer">Second view </a></li>
  <li><a href="http://tinypic.com/view.php?pic=zn3lh3&amp;s=6" rel="nofollow noreferrer">Third view</a></li>
  </ol>
  
  <p>Now when I click in any row in first view it goes to second view and show all related data in second view and when I click any item in Second view it goes to the third view and show detail information about that particular item.</p>
  
  <p>After explanation of app flow, now I show my code what I tried so far. Following a tutorial I just simply drag classes (XMLParser, Book) to my app for testing purpose.</p>
  
  <p>Code:</p>
  
  <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
   {
  NSURL *url = [[NSURL alloc] initWithString:@"Firstviewxmlurl"];
  NSXMLParser *xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url];
  XMLParser *parser = [[XMLParser alloc] initXMLParser];
  [xmlParser setDelegate:parser];
  BOOL success = [xmlParser parse];
  if(success)
      NSLog(@"No Errors");
  else
      NSLog(@"Error Error Error!!!");
   }
  </code></pre>
  
  <p>Now my XMLParser.m code is</p>
  
  <pre><code>- (XMLParser *) initXMLParser {
  
  [super init];
  
  appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
  
  return self;
    }
  
  - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName 
    namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName 
  attributes:(NSDictionary *)attributeDict {
  
  if([elementName isEqualToString:@"Collections"]) {
      //Initialize the array.
      appDelegate.books = [[NSMutableArray alloc] init];
  }
  else if([elementName isEqualToString:@"Collection"]) {
  
      //Initialize the book.
      aBook = [[Book alloc] init];
  
      //Extract the attribute here.
      aBook.bookID = [[attributeDict objectForKey:@"id"] integerValue];
  
      NSLog(@"Reading id value :%i", aBook.bookID);
  }
  
  NSLog(@"Processing Element: %@", elementName);
      }
  
     - (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:@"Collections"])
      return;
  if([elementName isEqualToString:@"Collection"]) {
      [appDelegate.books addObject:aBook];
  
      [aBook release];
      aBook = nil;
  }
  else 
      [aBook setValue:currentElementValue forKey:elementName];
  
  [currentElementValue release];
  currentElementValue = nil;
    }
  </code></pre>
  
  <p>Finaly my First view Class code is </p>
  
  <pre><code>    #pragma mark Table Methods
  
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
  return 1;
    }
  
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
   {
  //return [tblViewData count];
  return [appDelegate.books count];
   }
  
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
      {
  static NSString *CellIdentifier = @"SimpleTableIdentifier";
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  
  if (cell == nil)
  {
      cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
      cell.selectionStyle=UITableViewCellSelectionStyleGray;
      cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
  }
  //cell.textLabel.text=[[tblViewData objectAtIndex:indexPath.row]
                      // stringByReplacingOccurrencesOfString:@"*" withString:@""];
     Book *aBook = [appDelegate.books objectAtIndex:indexPath.row];
  
  cell.textLabel.text = aBook.title;
  
  if([deviceType isEqualToString:@"ipad"])
  {
      [cell.textLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:20]];
  }
  //cell.textLabel.font=[UIFont fontWithName:@"Walkway_SemiBold" size:16];
  return cell;
     }
  </code></pre>
  
  <p>After implementation of all the above Code i got the result in form of <a href="http://tinypic.com/view.php?pic=280qq36&amp;s=6" rel="nofollow noreferrer">this</a> Now at this point i confuse how can i pass my Second view xml file url and then third view url.my xml files are in this format</p>
  
  <p>First xml file</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Collections&gt; &lt;Collection id="5"&gt;&lt;title&gt;Allegroo&lt;/title&gt; &lt;/Collection&gt;
  </code></pre>
  
  <p>Second xml file</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;Collection id="5"&gt;&lt;colletciontitle&gt;Allegroo&lt;/colletciontitle&gt;  &lt;weaveimage&gt;"imageurl"   &lt;/weaveimage&gt;&lt;Rug id="48"&gt;&lt;Rugthumb&gt;"firstimageurl"&lt;/Rugthumb&gt;&lt;RugSku&gt;AL-637&lt;/RugSku&gt;&lt;/Rug&gt;&lt;Rug id="51"&gt;&lt;Rugthumb&gt;"Secondimageurl"&lt;/Rugthumb&gt;&lt;RugSku&gt;AL-641&lt;/RugSku&gt;&lt;/Rug&gt;
  </code></pre>
  
  <p>Third xml file</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;Rug id="47"&gt;&lt;Rugmainimage&gt;"imageurl"&lt;/Rugmainimage&gt; &lt;Rugtitle&gt;AL-636 Aged Indigo / Vintage Beige&lt;/Rugtitle&gt; &lt;Rugdiscription&gt;Hand Knotted
    Distressed Wool Pile / Cotton Foundation &lt;/Rugdiscription&gt;&lt;Availablesizes&gt;&lt;Size&gt;10x14&lt;/Size&gt;&lt;Size&gt;12x15&lt;/Size&gt;&lt;Size&gt;2x3&lt;/Size&gt;&lt;Size&gt;3x5&lt;/Size&gt;&lt;Size&gt;4x6&lt;/Size&gt;&lt;Size&gt;6x9&lt;/Size&gt;&lt;Size&gt;8x10&lt;/Size&gt;&lt;Size&gt;9x12&lt;/Size&gt;&lt;Runner&gt;2'6"x10'&lt;/Runner&gt;&lt;Runner&gt;2'6"x12'&lt;/Runner&gt;&lt;Runner&gt;2'6"x8'&lt;/Runner&gt;&lt;/Availablesizes&gt;&lt;/Rug&gt;
  </code></pre>
  
  <p>Any help in the form of link or sample code releated to my issue and suggestion will be highly appriated.Thanks</p>