Linq xml updating file
To specify the elements to be queried, we need to use “x Doc Object. You can see we have used similar expression on the linq query.While selecting, you can either create a dynamic object with the properties you need.Here again, need to be careful that, the constructed XElement is completely synchronized with the xml file’s format.And then, we need to add it to the ‘Xdocument’ objects corresponding element collection and finally overwrite the existing xml file.
Most of the samples involving LINQ to SQL involve using the designer built-into Visual Studio 2008 since it’s very productive.Notice that, we don’t need to reassign the modified XElement object as its being referenced internally from the XDocument object and apply the necessary changes while saving.Following is the code sample to do the modification: To delete a record, simply we need to retrieve it and then call “Remove” method of this XElement Object.Or you can declare in advance, a class with members and create object of that class.On above code, we have used the simplified dynamic object approach.
Search for linq xml updating file:
Surely, you will need to study about many more for working more deeply in this area.