2013-05-14 88 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