I have a XML file containing records like -
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfCLocation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<CLocation>
<CId>5726</CId>
<Long>0</Long>
<Lat>0</Lat>
<Status>Pending</Status>
</CLocation>
<CLocation>
<CId>5736</CId>
<Long>0</Long>
<Lat>0</Lat>
<Status>Processed</Status>
</CLocation>
</ArrayOfCLocation>
I take these records into List as -
XDocument xDocument = XDocument.Load(filePath);
List<T> list = xDocument.Descendants("CLocation")
.Select(c => (new T()
{
CId = Convert.ToInt32(c.Descendants("CId").FirstOrDefault().Value),
Lat = Convert.ToDouble(c.Descendants("Lat").FirstOrDefault().Value),
Long = Convert.ToDouble(c.Descendants("Long").FirstOrDefault().Value),
Status = (Status)Enum.Parse(typeof(Status), c.Descendants("Status").FirstOrDefault().Value)
}))
.Where(c => c.Status == Status.Pending)
.Take(listCount)
.ToList();
Now, I update T objects(setting their Lat/Log fields) in above collection and after processing these objects, I want to update these records back into XML file.
Can anyone please guide me for a efficient solution for how can I update these objects back into XML file.