I want to save records fetched from database in an XML file,
take x number of records from XML file into a custom collection List
process them and
While you could use a serializer - and many times this is the right answer - I personally would use Linq to XML which would allow you to be more flexible on how your XML should look like, i.e. to create the following XML from a collection foos
based on your class:
You could use:
var xml = new XElement("Foos", foos.Select( x=> new XElement("foo",
new XAttribute("Id", x.Id),
new XAttribute("property1", x.property1),
new XAttribute("property2", x.property2))));