0

我正在尝试从 xml 数据返回多行。我已将结果加载到字典中。下面的代码给了我最后一个结果(第 1 行或 Randy)。如何检索所有结果而不仅仅是最后一个?我正在寻找 [ID.text intValue] == CSHR_NUM 的 CSHR_POS_NAME。

dict = [resp objectForKey:@"TC"];
 if( ( dict == nil ) || ![dict isKindOfClass:[NSDictionary class]] ) {
  NSLog( @"WARNING: %@", [dict description]);
  return;
}

desc = [[dict objectForKey:@"CSHR_POS_NAME"]copy];
CashierNum = [[dict objectForKey:@"CSHR_NUM"]copy];

NSLog(@"Name: %@ and Cashier Number: %@",desc, CashierNum);

xml 输出的日志是:

<NewDataSet xmlns="">
  <TC diffgr:id="TC1" msdata:rowOrder="0">  
    <CSHR_POS_NAME>BRITTANY</CSHR_POS_NAME>
    <CSHR_NUM>66</CSHR_NUM>
  </TC>
  <TC diffgr:id="TC4" msdata:rowOrder="1">
    <CSHR_POS_NAME>Randy</CSHR_POS_NAME>
    <CSHR_NUM>7</CSHR_NUM>
  </TC>
</NewDataSet> 
</diffgr:diffgram>
4

1 回答 1

1

看来您有一系列带有"TC"键的字典。您不应该尝试将响应读取为数​​组,然后遍历字典吗?

于 2012-04-17T20:46:28.367 回答