Search code examples
iosnsdictionaryxmlreader

Accessing the xml values from NSDictionary


I am using this xmlreader. Here is my code

NSDictionary *xmlDict = [XMLReader dictionaryForXMLString:responseString error:&error1];
NSLog(@"XMLData: %@",xmlDict);

I can save and log the data and it looks like this.

response =     {
        Gpn0 =         {
            text = 10000;
        };
        Gsn0 =         {
            text = 4;
        };
        btn0 =         {
            text = up;
        };        
    };
}

But how can I access a single element from this dictionary?


Solution

  • NSDictionary *gpn0 = response[@"Gpn0"];
    NSNumber *gpn0_text = gpno[@"text"]; // note this is a numeric value
    
    NSDictionary *btn0 = response[@"btn0"];
    NSString *btn0_text = gpno[@"text"]; // note this is a string value    
    
    so on and so forth