XML Serialization (object --> xml)
protected void btnSerialize_Click(object sender, EventArgs
e)
{
//class has 3 attributes :[XmlRoot] ,[XmlElement], [XmlAttribute]
Book b = new Book();
b.Title = "Windows Forms";
b.Isbn = "728372837";
b.price = Convert.ToString("23.43");
b.quantity = 3;
string path = Server.MapPath("MyBook.xml");
XmlSerializer ser = new XmlSerializer(b.GetType());
TextWriter tw = new StreamWriter(path);
ser.Serialize(tw, b); //serialize all properties of
class to xml
tw.Close();
}