om prakash

om prakash

  • NA
  • 281
  • 104k

Reply ASap

Jul 24 2013 7:28 AM
 As i referrred these links....

http://www.codeproject.com/Articles/483055/XML-Serialization-and-Deserialization-Part-1

http://www.codeproject.com/Articles/487571/XML-Serialization-and-Deserialization-Part-2

b
ut i want dynamic xml serialization and deserialization...

i.e. i want to enter the values in output only.... i cant get correct idea....

 i tried  like this

//Serialization

private void button2_Click(object sender, EventArgs e)
        {
            List<Personal> pdetails = new List<Personal>();
            Personal personals = new Personal
            {
                ID = int.Parse(txtsno.Text),
                Name = txtname.Text,
                Phone = long.Parse(txtpno.Text),
                Address = txtaddr.Text
            };
            pdetails.Add(personals);

 XmlSerializer xmlser = new XmlSerializer(typeof(List<Personal>));
            StreamWriter swtr = new StreamWriter(@"d:\serialization.xml");
            xmlser.Serialize(swtr, pdetails);
            swtr.Close();
 }

//Deserialization

private void button3_Click(object sender, EventArgs e)
        {
            XmlSerializer xmlser = new XmlSerializer(typeof(List<Personal>));
            StreamReader srdr = new StreamReader(@"d:\serialization.xml");
            List<Personal>p = (List<Personal>)xmlser.Deserialize(srdr);
            srdr.Close();
        }


And also say some realtime examples for xml serialization and deserialization..?

when and where we use this.....purpose?v

Answers (3)