1
我該如何編寫它,以便將其保存在XML文件中?如何將此XML示例寫入XML文件?
<Stations>
<station id="1">
<title>Lehavim Railway station</title>
<latitude>31.369834</latitude>
<longitude>34.798207</longitude>
</station>
</Stations>
我有這部分代碼,但我不知道如何安排它,這樣如上圖所示,將被保存。
NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,
NSUserDomainMask,
YES);
NSString * filePath = [paths objectAtIndex:0];
filePath = [filePath stringByAppendingPathComponent:@"favorite"];
filePath = [filePath stringByAppendingPathExtension:@"xml"];
NSDictionary *station = [NSDictionary dictionaryWithObjectsAndKeys:
@"Lehavim Railway station",
@"31.369834",
@"34.798207",
, nil ];
[station writeToFile:filePath atomically:YES];
我也不知道如何更改站點部分中的id
。