NSData *xmlData = [[NSData alloc]initWithContentsOfFile:[NSString stringWithFormat:@"%@/People.xml",[[NSBundle mainBundle] resourcePath]]]; //2.将xmlData转化成xml文档 GDataXMLDocument *xmlDocument = [[GDataXMLDocument alloc]initWithData:xmlData options:0 error:nil]; //3.得到节点 GDataXMLElement *rootElement = xmlDocument.rootElement; //4.得到子节点 /*NSArray *elementArray = rootElement.children; //得到classone节点 GDataXMLElement *classoneElement = [elementArray firstObject]; for(GDataXMLElement *element in classoneElement.children) { //得到当前节点的文本值 NSLog(@"%@",element.stringValue); if (element.children.count>0) { GDataXMLElement *infoElement = [element.children lastObject]; //获得节点的全部属性和属性值 NSArray *attArray = infoElement.attributes; for (GDataXMLElement *attElement in attArray) { //得到属性名和属性值 NSLog(@"%@-%@",attElement.name,attElement.stringValue); } } } */ //模糊查找 NSArray *eArray = [rootElement nodesForXPath:@"//info" error:nil]; NSLog(@"%@",eArray);