前端之家收集整理的这篇文章主要介绍了
xml解析代码,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
通过路径解析 NSMutableArray * bookArr = [[NSMutableArray alloc] init]; NSArray * array = [root nodesForXPath:@"//book" error:nil]; for (GdataxMLElement * element in array) { // 创建模型 Book * book = [[Book alloc] init]; NSString * name = [[[element elementsForName:@"name"] lastObject] stringValue]; book.name = name; NSString * price = [[[element elementsForName:@"price"] lastObject] stringValue]; book.price = price; NSString * summary = [[[element elementsForName:@"summary"] lastObject] stringValue]; book.summary = summary; NSLog(@"summary:=======%@",summary); [bookArr addObject:book]; } NSLog(@"bookArr========%@",bookArr); 原文链接:https://www.f2er.com/xml/296044.html