GDataXMLNode
发布时间:2020-12-16 06:06:55 所属栏目:百科 来源:网络整理
导读:XML 解析思路大致相同 大家可以对比一下 方便使用#import "ViewController.h"#import "GDataXMLNode.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loadi
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 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |