Im a newbie trying to hack a weather app together. The app pulls down data from a weather api and uses a XPath parser along with libxml2
to grab the data. I have sorted most of the data apart from the icon url which is contained within a nodeChildArray
.
xnodes
is an NSMutableArray
which contains the following data for each day of the week:
nodeChildArray = (
开发者_如何学JAVA {
nodeContent = "http://www.worldweatheronline.com/images/wsymbols01_png_64/wsymbol_0003_white_cloud.png";
}
);
nodeName = weatherIconUrl;
What I want to do is grab the url from the nodeContent node within the nodeChildArray This is what I have so far.
for ( NSDictionary *node in xnodes )
{
for ( id key in node )
{
if ([key isEqualToString:@"nodeChildArray"])
{
NSLog(@"Key output %@",key);
}
}
}
How do I drill down the keys so to speak?
Worked it out, pretty simple really
NSString *url = [[[[xnodes objectAtIndex:0] objectForKey:@"nodeChildArray"] objectAtIndex:0] valueForKey:@"nodeContent"];
精彩评论