GDataXMLDocument *xmls = [[GDataXMLDocument alloc] initWithData:data2 options:nil error:nil];//获取根节点 GDataXMLElement* rootele = [xmls rootElement]; #import "GDataXMLNode.h" //属性 GDataXMLElement* newsId = [[rootele attributes] objectAtIndex:0];//转化为数组NSArray *array = [rootele children]; //NSLog(@"%@ count : %d", array,[array count]); for (int i = 0; i < [array count]; i++) { GDataXMLElement *ele = [array objectAtIndex:i]; // 根据标签名判断 if ([[ele name] isEqualToString:@"content"]) { // 直接读标签间的String contentStr = [NSString stringWithFormat:@"%@",[ele stringValue]]; // 读标签里面的属性 //NSLog(@"%@", [[elePic attributeForName:@"id"] stringValue]); } } //elementsForName: 取出指定名称的子节点 //GDataXMLElement* content1 = [[content elementsForName:@"content"] objectAtIndex:0]; //children: 取出所有的子节点 //GDataXMLElement* pic = [[pics children] objectAtIndex:0];