The simplest way to demonstrate Visual Basic's support for XML is to use it to serialize a class. The serialization of an object means that it is written out to a stream, such as a file or a socket. The reverse process can also be performed: an object can be deserialized by reading it from a stream and creating the XML from that stream. You may want to do this to save an object's data to a local file, or to transmit it across a network.
To help you understand XML serialization, let's examine a class named FilmOrder in the FilmOrder project. This class could be used by a company for processing a movie order.
An instance of FilmOrder corresponding to each order could be serialized to XML and sent over a socket from a client's computer. We are talking about data in a proprietary form here: an instance of FilmOrder being converted into a generic form—XML—that can be universally understood.
The System.Xml.Serialization namespace contains classes and interfaces that support the serialization of objects to XML, and the deserialization of objects from XML. Objects are serialized to documents or streams using the XmlSerializer class.
Let's look at how you can use XmlSerializer. To make the sample simpler, you'll use a console application. ...