Chapter 10: XML Serialization
So far in this book, you've examined many different ways of working with XML explicitly within the .NET Framework. That is to say, nearly everything that's been covered focused on working directly with XML and the various ways in which you can create, manipulate, and transform XML. In this chapter, we're going to examine an implicit method that the .NET Framework provides for working with XML. XML serialization provides a nearly transparent way of persisting object data as XML, and recreating the original objects from the XML data without the complexities of working directly with the XML Document Object Model (DOM) or XSLT transformations.
What Is Serialization?
Serialization is the process of converting an object to a form that can be readily transported. Generally, this means saving the object's data in a way that makes it easy to recreate the object later, through a process called deserialization. Serialization does not save any of the methods of an objectit is assumed that the object's code will be available during the deserialization process, and that the data unique to the object is all that is necessary to recreate the object. The serialized data can take many formats, but they all have one thing in common: the serialized data is not tied to the originating object or system, and the data contains all the information necessary to recreate an object that's identical to the original.