Skip to content

Instantly share code, notes, and snippets.

@soh335
Created March 15, 2009 12:27
Show Gist options
  • Save soh335/79401 to your computer and use it in GitHub Desktop.
Save soh335/79401 to your computer and use it in GitHub Desktop.
- (NSMutableDictionary *) _parse:(NSXMLNode *)node{
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
NSArray *childs = [node children];
for(NSXMLNode *_node in childs){
if([_node name]){
NSMutableDictionary *_d = [self _parse:_node];
if([[dict objectForKey:[node name]] count] == 0){
[dict setObject:[NSMutableDictionary dictionary] forKey:[node name]];
}
[[dict objectForKey:[node name]] addEntriesFromDictionary:_d];
}
}
if([childs count] < 2 && ![[childs lastObject] name]){
[dict setObject:[node stringValue] forKey:[node name]];
}
return dict;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment