我正在尝试从 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>