标签:xml解析
获取解析文件路径
NSString * xmlPath = [[NSBundle mainBundle] pathForResource:@"Citys" ofType:@"xml"];
2.初始化xml字符串
NSString * xmlStr = [NSString stringWithContentsOfFile:xmlPath encoding:NSUTF8StringEncoding error:nil];
3.初始化一个GDataXMLDocument对象 , 因为解析时所有的内容都是从该对象中获取,(所以需要将要解析的内容放入该对象)
self.document = [[GDataXMLDocument alloc]initWithXMLString:xmlStr options:0 error:nil];
self.city = [self.document nodesForXPath:@"//name" error:nil];
self.latitude = [self.document nodesForXPath:@"//latitude_e6" error:nil];
self.longitude = [self.document nodesForXPath:@"//longitude_e6" error:nil];
标签:xml解析
原文地址:http://qccccc.blog.51cto.com/6004423/1552626