IT Community - Software Programming, Web Development and Technical Support

XML Serialization Using C#...

This is a discussion on XML Serialization Using C#... within the C# Programming forums, part of the Software Development category; Hi, Could any one about explain xml serialisation...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C# Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 03-18-2008, 09:28 PM
shaalini shaalini is offline
D-Web Analyst
 
Join Date: Apr 2007
Posts: 342
shaalini is on a distinguished road
Default XML Serialization Using C#...

Hi,
Could any one about explain xml serialisation
__________________
Shaalini.S
Be the Best of Whatever you are...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-18-2008, 09:29 PM
bluesky bluesky is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 201
bluesky is on a distinguished road
Default Re: XML Serialization Using C#...

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-18-2008, 09:30 PM
bluesky bluesky is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 201
bluesky is on a distinguished road
Default Re: XML Serialization Using C#...

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.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-18-2008, 09:30 PM
bluesky bluesky is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 201
bluesky is on a distinguished road
Default Re: XML Serialization Using C#...

Suppose we have an object defined and instantiated as shown below:

class Person

{

private String personName;

private Int32 personAge;



public String Name

{

get

{

return personName;

}

set

{

personName = value;

}

}



public Int32 Age

{

get

{

return personAge;

}

set

{

personAge = value;

}

}

}
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-18-2008, 09:31 PM
bluesky bluesky is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 201
bluesky is on a distinguished road
Default Re: XML Serialization Using C#...

Demo class having public properties

Instantiation of the class is shown below:

Person oPerson = new Person();

oPerson.Name = "Anthony";

oPerson.Age = 38;
Let's say that for some reason, we wanted to save a copy of this object just as it is at this very moment. We could serialize it as an XML document that would look something like this:

<Person>
<Name>Anthony</Name>
<Age>38</Age>
</Person>
Then, at some later time when we needed to use the object again, we could just deserialize it and have our object restored to us just as it was at the moment we serialized it.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-18-2008, 09:32 PM
bluesky bluesky is offline
D-Web Analyst
 
Join Date: Jun 2007
Posts: 201
bluesky is on a distinguished road
Default Re: XML Serialization Using C#...

However XML serialization follows certain rules and the classes defined by us have to conform to these rules.

1. XML serialization serializes only the public fields and property values of an object into an XML stream.
2. XML serialization does not include type information.
3. XML serialization requires a default constructor to be declared in the class that is to be serialized.
4. XML serialization requires all properties that are to be serialized as read write properties. Read only properties are not serialized.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What is serialization vadivelanvaidyanathan ASP and ASP.NET Programming 2 09-11-2007 09:30 AM
Serialization and Deserialization vigneshgets VB.NET Programming 2 08-21-2007 12:41 AM
Serialization and Encoding vigneshgets C# Programming 1 08-01-2007 11:37 PM
Serialization and deserialization sivakumar Java Programming 1 07-17-2007 05:52 AM
Serialization leoraja8 Java Programming 1 05-10-2007 08:46 AM


All times are GMT -7. The time now is 04:58 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0