前端之家收集整理的这篇文章主要介绍了
GDataXMLNode,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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