im developing an iphone app using yahoo weather service ( i have a key ). i have 2 question :
there is any thing to do to much ( the first have the wanted location )? thank you.
I suspect this is an issue with XML namespaces. Depending on the framework used and the actual full XML you'd have to access the elements by their namespace. You might want to switch to another, DOM-based framework (not using NSXMLParser
), for example GDataXMLNode by Google. In a DOM-based framework you can access the individual nodes in a tree-like structure instead of building one on your own.
There are plenty of examples for this on the net, for example Building an RSS reader or How to read and write XML documents with GDataXML. But to give a quick example how this might look:
NSError *error = nil;
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:data options:0 error:&error];
if (doc == nil) { return nil; }
NSMutableDictionary *result = [[NSMutableDictionary alloc] init];
NSArray *lists = [doc nodesForXPath:@"/result/list" error:nil];
if ([lists count] > 0)
{
for (GDataXMLNode *list in lists) {
int listid = [self integerInNode:list forXPath:@"listid"];
NSString *listname = [self stringInNode:list forXPath:@"name"];
[result setValue:[NSNumber numberWithInt:listid] forKey:listname];
}
}
[doc release];
return [result autorelease];