从NSDictionary访问xml值

时间:2013-05-14 20:06:50

标签: ios nsdictionary xmlreader

我正在使用this xmlreader。这是我的代码

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

我可以保存并记录数据,它看起来像这样。

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

但是如何从这个字典中访问单个元素呢?

1 个答案:

答案 0 :(得分:1)

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