Q:

Using XML to save a persons text messages

Hi I'm making a windows phone application for the visually impaired. I have been thinking of ways to save the persons text message on the phone. I was thinking about using xml files to save a persons messages. I'm very stuck on how to even go about doing this. Any tips or ways i should approach this as i'm a very average coder. thanks 

A:

My recommendation - use JSON format instead of XML.
First download from NuGet two packages: Json.NET and my library WP.IO (or you can use the source code directly). Then you can use this:  
// example of saved object
public class MyObject
{
    public List<string> Messages { get; set; }
}

// save data
string json = JsonConvert.SerializeObject(myObject);
StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("messages.json", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(file, json);

// read back data
string read = await PathIO.ReadTextAsync("ms-appdata:///local/messages.json");
MyObject myObject = JsonConvert.DeserializeObject<int[]>(read);

