O'Reilly logo

Expert One-on-One™ C# Design and Development by John Paul Mueller

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 22. Serializing XML

XML databases have become more popular for storing small amounts of data, hierarchically formatted data, or larger amounts of simple data. The data appear in your application as a series of hierarchical objects, objects within objects, that end with an XMLDocument object holding everything together. Of course, storing a host of objects on your hard drive isn't going to work. You need some way to place those documents on the hard drive so that they conform to standard storage methods and some way to retrieve them so that you can rebuild the object structure as needed. The storage process is serialization, while loading the document from disk relies on deserialization. The resulting disk on file is in XML format.

Fortunately, Visual Studio has a considerable number of storage technologies built into it. Often you can read and write XML data without worrying too much about the underlying structure because the XML file is truly data. However, you may want to store the data as structured settings or configuration information. Perhaps you want to provide custom handling of the data so that the application can interact with this data in a specific way. When you want to interact with XML in these specialized ways, you must create a customized class to perform the task. The class tells how to serialize and deserialize the data so your application can interact with them properly.

This chapter helps you understand the specialized techniques you can use to create applications ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required