How do we update an existing XML file in C#

moecsev

New Member
I have an existing xml file which I want to update.\[code\]using (IsolatedStorageFile ISF = IsolatedStorageFile.GetUserStoreForApplication()) { // Load the xml document for reading using (IsolatedStorageFileStream ISFS = ISF.OpenFile(FILE_NAME, FileMode.Open, FileAccess.ReadWrite)) { XDocument file= XDocument.Load(ISFS); //Edit the file file.Save(ISFS); } }\[/code\]The problem is whenever I use \[code\]file.Save(ISFS)\[/code\], and then try to load it again, using same method, an error is reported\[code\] System.Xml.XmlException was unhandled by user code HResult=-2146232000 Message=Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 25, position 14.\[/code\]
 
Back
Top