2013-05-14 41 views
0

我正在使用this xmlreader。这里是我的代码从NSDictionary访问xml值

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

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

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

但是我怎样才能从这个字典中访问单个元素?

+0

'的NSDictionary *内=根节点[@ “Gpn0”];' – 2013-05-14 20:08:37

+0

@ H2CO3由根节点,你的意思是从我的问题 “反应”? – aVC

+0

如果你有一个指向该字典的指针,那么是的。 – 2013-05-14 20:11:55

回答

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