XML 解析思路大致相同 大家可以对比一下 方便使用
#import "ViewController.h"
#import "GDataXMLNode.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
NSString *path = [[NSBundle mainBundle] pathForResource:@"user" ofType:@"xml"];
NSString *str = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
//xml解析器
GDataXMLDocument *document = [[GDataXMLDocument alloc] initWithXMLString:str options:0 error:nil];
NSArray *array = [document nodesForXPath:@"/Users/User/name" error:nil];
for (GDataXMLElement *nameElement in array)
{
NSLog(@"%@",[nameElement stringValue]);
// [nameElement elementsForName:<#(NSString *)#>];
// [nameElement attributeForName:<#(NSString *)#>];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
08-12
08-12
08-12