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
Using the code below (Class T Taken from your code snippet) you will be able to serialize into an XML file with ease, and without the hassle of implementing ISerializable
[Serializable()]
public class T
{
public int Id {get; set;}
public string property1 {get; set;}
public string property2 {get; set;}
}
...
List data = new List()
... // populate the list
//create the serialiser to create the xml
XmlSerializer serialiser = new XmlSerializer(typeof(List));
// Create the TextWriter for the serialiser to use
TextWriter filestream = new StreamWriter(@"C:\output.xml");
//write to the file
serialiser.Serialize(filestream , data);
// Close the file
filestream.Close();