Thanks for the description, Greg. I am using similar methods to save GDataEntryWorksheet (for spreadsheets) to disk and then retrieving it later. Interestingly, I'm seeing an issue...
// writing to file (where spreadsheet is a GDataEntrySpreadsheet object)
spreadsheet = [self selectedSpreadsheet];
NSString *xmlRepresentation = [[spreadsheet XMLElement] XMLString];
NSError *fileError = nil;
BOOL ok = [xmlRepresentation writeToFile:spreadsheetPath atomically:YES encoding:NSUnicodeStringEncoding error:&fileError];
if (!ok) {
NSLog(@"Error writing file at %@\n%@",
spreadsheetPath, [fileError localizedFailureReason]);
}
// reading from file
NSError *fileError = nil;
NSString *xmlRepresentation = [[NSString alloc]
initWithContentsOfFile:spreadsheetPath
encoding:NSUnicodeStringEncoding
error:&fileError];
if (fileError) {
NSLog(@"Error reading file at %@\n%@",
spreadsheetPath, [fileError localizedFailureReason]);
}
NSError *xmlError = nil;
NSXMLElement *xmlElement = [[[NSXMLElement alloc] initWithXMLString:xmlRepresentation error:&xmlError] autorelease];
if (xmlElement) {
spreadsheet = [[[GDataEntrySpreadsheet alloc] initWithXMLElement:xmlElement parent:nil] autorelease];
} else {
NSLog(@"Error reading xml: %@", xmlError);
}
My xmlElement isn't getting set and I'm seeing the following error:
2011-07-19 13:06:36.482 SpreadsheetSample[88919:903] Error reading xml: Error Domain=NSXMLParserErrorDomain Code=201 UserInfo=0x3339e90 "Line 1: Namespace prefix gd for etag on entry is not defined
I think this is because the <entry etag> data I'm receiving from Google looks like this:
<entry gd:etag=""GU1VQkhSACt7ImBr"">
When I build xmlRepresentation manually and change the <entry etag> to:
<entry etag=""GU1VQkhSACt7ImBr"">
everything works as expected. Being pretty new to iOS and GData, I am planning on parsing out the 'gd:' from xmlRepresentation. Is there a better way to do this?
Sincerely,
m@