使用GData Library更新节点

时间:2011-06-23 06:58:16

标签: xcode ios4 xml-parsing gdata-api objective-c-2.0

嗨,我正在使用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]);

}

但是它现在给我任何结果所以请帮助我。

0 个答案:

没有答案