Net-informations.com
SiteMap  | About    

XML DeSerialization

XML is a general purpose tag based language and very easy to transfer and store data across applications. XML Serialization is the process of serializing a .Net Object to the form of XML file or from an XML to .Net Object.

During XML serialization, only the public properties and fields of an object are serialized. The following C# source code shows how to De-Serialize the DataSet as it is streamed from an XML file back into memory.




using System;
using System.Data;
using System.Windows.Forms;
using System.Xml.Serialization ;
using System.IO;


namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(DataSet));
            FileStream readStream = new FileStream("serialXML.xml", FileMode.Open);
            ds = (DataSet)xmlSerializer.Deserialize(readStream);
            readStream.Close();
            dataGridView1.DataSource = ds.Tables[0];
        }


   }
}

Click here to download serialXML.xml






net-informations.com (C) 2017    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.