I have been struggling with this one issue for too long, and I know I must be missing something fairly simple. I have been searching and can’t seem to find the solution…
I have an XML file that I am loading in the app in the solutions window “Data/quotes.xml” (it has a build action of content). I am able to read, search, and display everything fine. The issue is that I have an element in the XML ‘favorite’ and by default it
is a 0 (zero). I have a button that allows the user to click favorite. I can search for and find the record but all attempts to save the element value with a 1 (one) fails.
It looks like the issue is that I need a stream to use xmlDoc.Save(); and I can’t seem to get a IsolatedStorageFileStream to work I am guessing because this file is not in Isolated Storage. I have tried many samples of code posted in threads and blogs, but
the save doesn’t work or it throws an exception.
The goal is something like:
var results = (from q in quote_xml.Descendants("quote") where int.Parse(q.Element("quote_id").Value) == int.Parse(this_quote_id) select q);
if (results.Count() > 0)
{
foreach (XElement xe in results)
{
xe.SetElementValue("favorite", "1");
doc.Save();
}
}
Thanks for the clarification -- dealing with data on the phone device seems to be challenging... I hope this gets easier as i get more familiar with the framework / devices.