| Author: Vidhya 26 Jul 2008 | Member Level: Gold | Rating: Points: 1 |
The primary purpose of XML serialization in the .NET Framework is to enable the conversion of XML documents and streams to common language runtime objects and vice versa. Serialization of XML to common language runtime objects enables one to convert XML documents into a form where they are easier to process using conventional programming languages. On the other hand, serialization of objects to XML facilitates persisting or transporting the state of such objects in an open, standards compliant and platform agnostic manner.
XML serialization in the .NET Framework supports serializing objects as either XML that conforms to a specified W3C XML Schema Definition (XSD) schema or that is conformant to the serialization format defined in section five of the SOAP specification. During XML serialization, only the public properties and fields of an object are serialized. Also, type fidelity is not always preserved during XML serialization. This means that if, for instance, you have a Book object that exists in the Library namespace, there is no guarantee that it will be deserialized into an object of the same type. However, this means that objects serialized using the XML serialization in the .NET Framework can be shipped from one machine to the other without requiring that the original type be present on the target machine or that the XML is even processed using the .NET Framework. XML serialization of objects is a useful mechanism for those who want to provide or consume data using platform agnostic technologies such as XML and SOAP.
XML documents converted to objects by the XML serialization process are strongly typed. Data type information is associated with the elements and attributes in an XML document through a schema written in the W3C XML Schema Definition (XSD) Language. The data type information in the schema allows the XmlSerializer to convert XML documents to strongly typed classes.
|
| Author: Ratheesh 29 Jul 2008 | Member Level: Gold | Rating: Points: 1 |
Object Serialization is a process through which an object's state is transformed into some serial data format, such as XML or a binary format. For example, you can serialize an object and transport it over the Internet using HTTP between a client and a server. On the other end, deserialization reconstructs the object from the stream. XML was designed to be a technology for data exchange across heterogeneous systems. It can be easily transmitted between distributed components because of its platform independence and its simple, text-based, self-describing format. In this article I will discuss the serialization of custom business objects to XML and reconstruction the object back from the XML string, using C#. This process is called XML serialization and is very well supported by .Net.
Some good uses for serialization/deserialization include:
Storing user preferences in an object. Maintaining security information across pages and applications. Modification of XML documents without using the DOM. Passing an object from one application to another. Passing an object from one domain to another. Passing an object through a firewall as an XML string.
|