您是否创建了 XML 文件/数据?我建议您为节点放置命名空间,以便更容易跟踪它们。例如:
<sheetData xmlns="http://mypage.net/sheetdata">
<row r="7" spans="5:6" x14ac:dyDescent="0.25" xmlns="http://mypage.net/r7">
<c r="E7" t="s">
<v>0</v>
</c>
<c r="F7" t="s">
<v>1</v>
</c>
</row>
<row r="8" spans="5:6" x14ac:dyDescent="0.25" xmlns="http://mypage.net/r8">
<c r="E8" t="s">
<v>2</v>
</c>
<c r="F8">
<v>9890234654</v>
</c>
</row>
</sheetData>
有了命名空间,下面是一个更新值的示例代码:
//The sample xml data is assigned to this NSData object: myXMLData
//Create a GDataXMLDocument
NSError *error = nil;
GDataXMLDocument *doc = [[GDataXMLDocument alloc] initWithData:myXMLData options:0 error:&error];
//build a namespace dictionary
NSDictionary *ns = [NSDictionary dictionaryWithObjectsAndKeys:@"http://mypage.net/sheetdata", @"sd", @"http://mypage.net/r7", @"r7", "http://mypage.net/r8", @"r8", nil];
//Now here are some codes to change the value
NSError *err = nil;
GDataXMLNode *row8 = [[doc nodesForXPath:@"//r8:row" namespace:ns error:&err] objectAtIndex:0];
//Need to change value of second node
GDataXMLNode *f8 = [[row8 children] objectAtIndex:1];
GDataXMLNode *f8v = [[f8 children] objectAtIndex:0];
f8v.stringValue = @"9503452366";
//doc now has the xml with updated value. Just get the XML data, doc.XMLData, from it then convert it as you please