1
我使用Google API檢索當前天氣。XML XCode屬性
- (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];
}
與上述,我得到3個條件。我需要的只是當前,我該如何解決這個問題?這裏是xml code。
我想只檢索嵌套在「current_conditions」內的「條件」。謝謝!
'如果([的ElementName isEqualToString:@「current_conditions」])' – beryllium 2012-04-11 13:09:30
這也正是我所做的,但不解決問題 – Hexark 2012-04-12 09:44:47
但是,如果你找到一個比我的更好的方式(下)請分享它。 – Kuba 2012-04-12 14:37:44