title: Parser XML with NSXMLParser
body: <p>I got a question with xml parsing. Normally,the XML file style like this:</p>
  <pre><code>&lt;person&gt;
       &lt;name&gt; abc &lt;/name&gt;
       &lt;age&gt; 19 &lt;/age&gt;
       &lt;gender&gt; male &lt;/gender&gt; 
  &lt;/person&gt;
  </code></pre>
  <p>In this way, we use</p>
  <pre><code>elementName isEqualToString:@&quot;name&quot;
  elementName isEqualToString:@&quot;age&quot;
  elementName isEqualToString:@&quot;gender&quot;
  </code></pre>
  <p>to identify the element.</p>
  <p>Now, I'm facing a xml file style like:</p>
  <pre><code>&lt;person&gt;
       &lt;element type=&quot;name&quot;&gt;abc&lt;/element&gt;
       &lt;element type=&quot;age&quot;&gt;19&lt;/element&gt;
       &lt;element type=&quot;gender&quot;&gt;male&lt;/element&gt; 
  &lt;/person&gt;
  </code></pre>
  <p>In this situation, we can't use</p>
  <pre><code>elementName isEqualToString:@&quot;name&quot;
  </code></pre>
  <p>So I tried to use</p>
  <pre><code>if ([elementName isEqualToString:@&quot;element&quot;]) ｛
     if ([[attributeDict objectForKey:@&quot;type&quot;] isEqualToString:@&quot;name&quot;){
        .....
     }
  ｝
  </code></pre>
  <p>to identify the &quot;name&quot;, but it gave me a none value, there is nothing if i tried to get the value of &quot;name&quot;.</p>
  <p>So, does anyone have any suggestions to fix this problem? thanks</p>
  <p>PS: Here are part of my code</p>
  <pre><code>- (void)parser:(NSXMLParser *)parser
  didStartElement:(NSString *)elementName
    namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName
      attributes:(NSDictionary *)attributeDict {
      
      
      if ( [elementName isEqualToString:@&quot;area&quot;]) {
          if ([[attributeDict objectForKey:@&quot;type&quot;] isEqualToString:@&quot;location&quot;]) {
              NSString *description = [attributeDict objectForKey:@&quot;description&quot;];
              
              NSArray *lineEntry = [[NSArray alloc] initWithObjects:description,nil ];
              NSArray *lineKeys = [[NSArray alloc] initWithObjects:@&quot;description&quot;,nil];
              NSDictionary *dictItem = [[NSDictionary alloc] initWithObjects:lineEntry forKeys:lineKeys];
              
              [lineKeys release];
              [lineEntry release];
              
              [dataLoad addObject:dictItem];
              [dictItem release];
          }
          
      }
      
      if ([elementName isEqualToString:@&quot;forecast-period&quot;]) {
          
          NSString *index = [attributeDict objectForKey:@&quot;index&quot;];
          NSString *time = [attributeDict objectForKey:@&quot;start-time-local&quot;];
          
  
          NSArray *indexEntry = [[NSArray alloc] initWithObjects:index,time,nil];
          NSArray *indexKey = [[NSArray alloc] initWithObjects:@&quot;index&quot;,@&quot;start-time-local&quot;,nil];
  
          NSDictionary *dicIndex = [[NSDictionary alloc] initWithObjects:indexEntry forKeys:indexKey];
          
          [indexEntry release];
          [indexKey   release];
          
          [weatherLoad addObject:dicIndex];
          [dicIndex release];
          
          
      }
  }
  </code></pre>
  <p>it worked fine with those 2 parts, but it doesn't work if i try to get &quot;forecast_icon_code&quot;,&quot;air_temperature_minimum&quot;,&quot;air_temperature_maximum&quot;,&quot;precis&quot;.</p>
  <pre><code>&lt;forecast-period index=&quot;1&quot; start-time-local=&quot;2010-11-19T00:00:00+11:00&quot; end-time-local=&quot;2010-11-20T00:00:00+11:00&quot; start-time-utc=&quot;2010-11-18T13:00:00Z&quot; end-time-utc=&quot;2010-11-19T13:00:00Z&quot;&gt;
  &lt;element type=&quot;forecast_icon_code&quot;&gt;1&lt;/element&gt;
  &lt;element type=&quot;air_temperature_minimum&quot; units=&quot;Celsius&quot;&gt;12&lt;/element&gt;
  &lt;element type=&quot;air_temperature_maximum&quot; units=&quot;Celsius&quot;&gt;24&lt;/element&gt;
  &lt;text type=&quot;precis&quot;&gt;Sunny.&lt;/text&gt;
  &lt;/forecast-period&gt;
  </code></pre>
  <p>Any suggestions? BTW, the whole xml file is here: <a href="ftp://ftp2.bom.gov.au/anon/gen/fwo/IDV10753.xml" rel="nofollow noreferrer">ftp://ftp2.bom.gov.au/anon/gen/fwo/IDV10753.xml</a></p>