使用 GData 库更新节点
您好,我正在使用 Gdata 库,但我被困在一个地方,我想从 xml 节点更新特定数据。下面给出的是我正在尝试更新的代码,
-(void)UpdateTheXMLNode { NSArray *docdirpath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *fileLoc = [[docdirpath objectAtIndex:0] stringByAppendingPathComponent:@"SomeXML.xml"]; NSData *xmlData = [NSData dataWithContentsOfFile:fileLoc]; GDataXMLDocument *doc = [[GDataXMLDocument alloc]initWithData:xmlData options:0 error:nil]; NSArray *a = [doc.rootElement elementsForName:@"row"]; NSLog(@"data before = %@",[[[a objectAtIndex:0] childAtIndex:1]stringValue]); [[[a objectAtIndex:0] childAtIndex:1]setStringValue:@"Yahooo"]; [a writeToFile:fileLoc atomically:YES]; NSLog(@"data after = %@",[[[a objectAtIndex:0] childAtIndex:1]stringValue]); }
但可惜它现在给了我任何结果,所以请帮助我。
hi i am working with the Gdata library and i am stuck at one place i want to update a particular data from the xml node. Given below is my code that i am trying to update
-(void)UpdateTheXMLNode { NSArray *docdirpath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *fileLoc = [[docdirpath objectAtIndex:0] stringByAppendingPathComponent:@"SomeXML.xml"]; NSData *xmlData = [NSData dataWithContentsOfFile:fileLoc]; GDataXMLDocument *doc = [[GDataXMLDocument alloc]initWithData:xmlData options:0 error:nil]; NSArray *a = [doc.rootElement elementsForName:@"row"]; NSLog(@"data before = %@",[[[a objectAtIndex:0] childAtIndex:1]stringValue]); [[[a objectAtIndex:0] childAtIndex:1]setStringValue:@"Yahooo"]; [a writeToFile:fileLoc atomically:YES]; NSLog(@"data after = %@",[[[a objectAtIndex:0] childAtIndex:1]stringValue]); }
But alas its now giving me any results so please help me out it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论