A convenient and nonintrusive XML parser utility for iOS and OSX , based on Apple's NSXMLParser.
###建议直接使用XMLParser_3里面的工具类,XMLParser_1和XMLParser_2可以用于对比学习。
##Use HYXMLParse to Parser XML data
// need Model Class Name(VideoMolel) and XML ChildElementName(video)
//1、创建HYXMLParse对象,
//参数:1、Model Class Name
// 2、XML 需要解析的节点的名 video
// 3、通过block传递字典转模型的方法 ---> 根据实际需求,可以用KVC也可以用MJExtension
HYXMLParser* parser = [[HYXMLParser alloc] initWithModelClassName:@"VideoModel" withElementName:@"video" modelFromBlock:^(NSDictionary<NSString *,NSString *> *dataDic, id model) {
// 第一种字典转模型:KVC
// [model setValuesForKeysWithDictionary:dataDic];
// 第二种字典转模型:MJExtension
[model mj_setKeyValues:dataDic];
}];
//NSData -> NSMutableArray of models
NSMutableArray* models = [parser modelsArrayFromData:data];
###The mdels is you want ,That OK!