title: Parsing XML data to NSMutableArray iOS - iPhone
body: <p>This is the XML data:</p>
  
  <pre><code>&lt;Categorys&gt; 
      &lt;Category&gt;  
          &lt;categoryId&gt;25&lt;/categoryId&gt;  
              &lt;categoryName&gt;My Photos&lt;/categoryName&gt;                                  
                  &lt;categoryDescription&gt;Description&lt;/categoryDescription&gt;      
              &lt;categoryIconPath&gt;7.jpg&lt;/categoryIconPath&gt;      
              &lt;userId&gt;2&lt;/userId&gt;  
              &lt;categoryStatus&gt;ON&lt;/categoryStatus&gt;  
          &lt;publicPrivate&gt;Private&lt;/publicPrivate&gt;
      &lt;/Category&gt;
  ......more categories
  &lt;Categorys&gt;
  </code></pre>
  
  <p>Here I want to get the <code>&lt;categoryName&gt;</code> values into my <code>NSMutableArray categList</code>. </p>
  
  <p>The code I have used is:</p>
  
  <pre><code>- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI
                                         qualifiedName:(NSString *)qualifiedName 
                                            attributes:(NSDictionary*)attributeDict {
  
      if ( [elementName isEqualToString:@"categList"]) {
          // addresses is an NSMutableArray instance variable
          if (!categList)
              categList = [[NSMutableArray alloc] init];
          return;
      }
  
      NSLog(@"StartedElement %@", elementName);
  
      element = [NSMutableString string];
  
  }
  
  
  - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string {
  
      if(element == nil)
  
          element = [[NSMutableString alloc] init];
  
          [element appendString:string];
  
  }
  
  - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName 
                                        namespaceURI:(NSString *)namespaceURI
                                       qualifiedName:(NSString *)qName {
  
      NSLog(@"Found an element named: %@ with a value of: %@", elementName, element);
  
      if ([elementName isEqualToString:@"categoryName"]) {
  
          NSLog(@"\n\n\nfound::::::::::::::: %@", element);
  
          category = element;
  
          NSLog(@"category:::: %@", category);
  
      }
  
      [categList addObject:element];
      NSLog(@"categList*************** %@", categList);
  }
  </code></pre>
  
  <p>But I am not getting the category names in my <code>NSMutableArray categList</code>:</p>
  
  <p>Whats wrong in my code? :(</p>
  
  <p>Thanks</p>