Hi I use this code to save an xml file
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("test.xml", FileMode.Create, myIsolatedStorage))
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
using (XmlWriter writer = XmlWriter.Create(isoStream, settings))
{
writer.WriteStartElement("t", "test", "urn:test");
writer.WriteStartElement("TestA", "");
writer.WriteString(lbTestA.Text);
writer.WriteEndElement();
writer.WriteStartElement("TestB", "");
writer.WriteString(lbTestB.Text);
writer.WriteEndElement();
writer.WriteEndDocument();
writer.Flush();
}
}
}
And it created the right xml file checked with Isolated Storage Explorer for WP7, now I want to read only the values stored in the and Tags the only code I could use was this one
private void loadgame_Click(object sender, EventArgs e)
{
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
IsolatedStorageFileStream isoFileStream = myIsolatedStorage.OpenFile("test.xml", FileMode.Open);
using (StreamReader reader = new StreamReader(isoFileStream))
{
lsScore.DataContext = reader.ReadToEnd();
}
}
}
But it just reads the whole xml file as it is just a text, any ideas ?
Code reading the xml file. I used a seperator between the values and later used the .Split to seperate the values
The XML File
The output from string
score = test.Root.Value.ToString();is 300,-200
I think this sums it all up.