How can use XML Serialization in VB.Net and C#?

Xml-tool-iconAs you know there are different types of machines and OS in the world that they have to connect to each other and transfer data but each system has own structure and may cannot understand the data that are coming from other system(s), but technology has solved it for them! One of the solutions is XML

What is XML?

XML  (Extensible Markup Language) is a format that was designed to transport and store data.Both machine and human can understand XML.

If you want to learn more about the XML I suggest you to go this link.

Before start you must import these classes:


Imports System.IO
Imports System.Xml.Serialization


using System.IO;
using System.Xml.Serialization;


 Private Sub CreateXML()
        Dim OFileStream As FileStream = _
New FileStream("C:/CodingTips.XML", _
        Dim Oxmlsr As XmlSerializer = _ 
New XmlSerializer(GetType(DateTime))
        Oxmlsr.Serialize(OFileStream, System.DateTime.Now.ToString)
    End Sub


private void CreateXML()
    FileStream OFileStream = new FileStream("C:/CodingTips.XML",_
    XmlSerializer Oxmlsr = new XmlSerializer(typeof(DateTime));
    Oxmlsr.Serialize(OFileStream, System.DateTime.Now.ToString());

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s