C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




XmlSerializer


Posted Date: 01 Sep 2008      Total Responses: 4

Posted By: lakshmi       Member Level: Gold     Points: 1



what is ment my XmlSerializer?
when i want to use the XmlSerializer?





Responses

Author: chaitanya lakshmi    01 Sep 2008Member Level: SilverRating:     Points: 3

XML Serializer is nothing but the API which converts the objects into the XML Document and this is used when one wants to convert the serialized objects into XML Document.

For Example if you want to convert some details of the Person into object then you can do that using XML serializer with out writing any extra code to serialize them and convert them into XML document.



Author: Sherrie    03 Sep 2008Member Level: SilverRating:     Points: -20

Serialization allows programms to persist objects by storing then in files. In the case of this tutorial, into XML files. XML has become the standard for storage in the recent years and its good to see that with XML serialization built into the .NET framework, it will be very simple to build applications which can interop well with any other software, Microsoft or not.
ShoppingList myList = new ShoppingList();
myList.AddItem( new Item( "eggs",1.49 ) );
myList.AddItem( new Item( "ground beef",3.69 ) );
myList.AddItem( new Item( "bread",0.89 ) );

// Serialization
XmlSerializer s = new XmlSerializer( typeof( ShoppingList ) );
TextWriter w = new StreamWriter( @"c:\list.xml" );
s.Serialize( w, myList );
w.Close();

// Deserialization
ShoppingList newList;
TextReader r = new StreamReader( "list.xml" );
newList = (ShoppingList)s.Deserialize( r );
r.Close();



Author: Sabu C Alex    18 Sep 2008Member Level: GoldRating:     Points: 3

hai lakshmi

Xml Serialization
--------------------------------------
Serialization is the process of converting an object to a format that can be transfer through a network or can be save to a location(file or DB).
The serialized data contains the object's informations like Version,Culture,PublicKeyToken,Type etc.
Deserialization is the reverse process of serialization, that is reconstructing the object from the serialized state to its original state.

if u want to see an eg: of XML serialization using XmlSerializer
see my resource

http://www.dotnetspider.com/resources/20669-Xml-Serialization.aspx



Author: Sherrie    18 Sep 2008Member Level: SilverRating:     Points: -20

XML Serializer can be used to store and retrieve objects from XML documents.
This class can be used to store and retrieve objects from XML documents.
It can traverse the list of public variables of an object and generated a XML document with variable values.
It can also do the opposite, by loading a previously generated XML document and restore the original object public variable values.It generates an xml document from the sax events. This serializer is used for serializing to any XML document format, ie. SVG, WML, VRML, et. al.
public class Serializer
{
public static string ObjectToString(object obj)
{
try
{
XmlSerializer serializer = new XmlSerializer(obj.GetType(), "");
StringWriter writer = new StringWriter();
serializer.Serialize(writer, obj, null);
return writer.ToString();
}
catch(Exception)
{
}
return null;
}
public static bool StringToObject(string data,out object obj)
{
obj = null;
try
{
XmlSerializer serializer = new XmlSerializer (obj.GetType(),"");
StringReader reader = new StringReader(data);
obj=serializer.Deserialize(reader);
return true;
}
catch(Exception)
{

}
return false;
}
}



Post Reply
You must Sign In to post a response.
Next : xml and xsl
Previous : Line break in XML
Return to Discussion Forum
Post New Message
Category: XML

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use