I'm trying to load xml data saved in the isolated storage, but I always get an error. I use the following code to load xml data saved in the isolated storage
IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication();
storage.CreateDirectory("Highscores");
using (var isoFileStream = new IsolatedStorageFileStream("Highscores\\scores.xml", FileMode.OpenOrCreate, storage))
{
using (XmlReader reader = XmlReader.Create(isoFileStream))
{
XDocument xml = XDocument.Load(reader);
int i = 0;
foreach (var score in xml.Root.Element("Highscores").Elements())
{
Count_to_10.Page2.Highscores.scores[i++] = score.Value.ToString();
}
}
}
But I get the following error
Root element is missing.
in this line
XDocument xml = XDocument.Load(reader);
The xml file is:
<HighscoreTable>
<Highscores length="25">
<score>00:00:09.000</score>
<score>00:00:07.000</score>
<score>00:00:02.000</score>
<score>00:00:04.000</score>
</Highscores>
</HighscoreTable>
I'd be glad if you'd help me find the source of the error.