2008-08-20
| Table of Contents: |
| Rate This Article: | Add This Article To: |
( Page 1 of 6 )
As the registry gets ever more crowded and CONFIG files prove less than adequate, think again about using XML serialization to solve your data storage woes.
Developers have a wealth of data storage options. You can store data in something as simple as a plain text file (which is what an INI file provides). A .NET developer might choose to store data in a CONFIG file. Of course, there is the registry or a SQL Server connection to consider as well. In short, there are many options for storing data. However, none of these solutions provides elegant and extremely flexible storage provided by an XML serialization solution. Using XML serialization, you don’t have to worry where your data appears—it normally appears right with the application, making an XCopy installation (versus a custom installation application package) quite feasible.
What is XML Serialization?
XML serialization is a process where you save application data to an XML file. The data can appear in any format. You can save individual values or lists of values. Precisely what you save is up to you. Essentially, what you’re creating is a special kind of CONFIG file—one that you define specifically for your needs.
The files produced by XML Serialization aren’t special in any way. You can easily read them using any standard XML editor or even Internet Explorer as shown in Figure 1. This is the XML serialization file for the example in this article. As you can see, nothing particularly special, yet this feature is extremely flexible and powerful.
Figure 1: XML serialization produces a standard XML file that you can edit using any editor.

Unlike many other forms of storage, XML serialization isn’t set aside for any particular task. For example, when you create registry entries, you do it to store application settings. Likewise, CONFIG files normally contain only application settings. Standard XML files normally contain only data. However, when using XML serialization, it’s expected that you’ll place any kind of data you want in the file—application settings, user data, anything. In fact, Figure 1 shows a combination of application settings and user data.
![]() |
|


