i have a situation I am getting data from the server as xml, i converted that data into NSDictionary using https://github.com/Insert-Witty-Name
MY xml is like
<Game>
<userid></userid>
<name></name>
<friendId></friendId>
<friendName></friendName>
</Game>
the value Game and all other items can change, so first I need to find out the name of the first element that is a game =>
I converted this through above Library now I am getting as
xmlString = [NSString stringWithFormat:@"<Game><userid>12</userid><userName>ben</userName><friendId>41</friendId><friendName>Ben1</friendName></Game>"];
NSDictionary *dict = [XMLReader dictionaryForXMLString:xmlString error:nil];
NSString *string;
string = [dict objectForKey:@"Game"];
NSLog(@"name is :%@",string);
and the output is
{
friendId = 41;
friendName = Ben1;
userName = ben;
userid = 12;
}
I need to find out the root element name of xml and how to access these values in NSDictionary with objectForKey
use Enumerator to iterate and find value based on the key or
[[dict objectForKey:@"Game"] allKeys]to get all keys