I am using Google’s API to retrieve the current weather.
- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName
namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName
attributes:(NSDictionary *)attributeDict
{
if([elementName isEqualToString:@"condition"])
{
NSString* string = [attributeDict objectForKey:@"data"];
NSLog(@"The weather is now %@", string);
}
[self setUIState:ACTIVE_STATE];
}
With the above, I am getting 3 conditions. All I need is the current, how do I solve this? Here is the xml code.
I am trying to retrieve only the “condition” which is nested inside “current_conditions”. Thanks!
Use BOOL variable to check if you are in the current_conditions. Example:
BOOL retrieveCurrentCondition;
set this in initializer to NO, then
and in
didEndElementback to NO.Meanwhile you can implement methods to get whatever you want
if(retrieveCurrentCondition)