我尝试了很多方法来获取 NSXMLParser 的值,但我没有成功。attributeDict objectForKey 对我不起作用。
这是我的代码:
- (void) parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict
{
if (![elementName isEqual:@"item"])
return;
CerereIndemnizatieDoc *cerereIndemnizatie = [[CerereIndemnizatieDoc alloc] init];
NSString * index = [attributeDict objectForKey:@"id"];
NSString * name = [attributeDict objectForKey:@"nume"];
cerereIndemnizatie.id = index;
cerereIndemnizatie.nume = name;
if (!cereriIndemnizatie)
cereriIndemnizatie = [[NSMutableArray alloc] init];
[cereriIndemnizatie addObject:cerereIndemnizatie];
}