| Author: chaitanya lakshmi 01 Sep 2008 | Member Level: Silver | Rating: 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 2008 | Member Level: Silver | Rating: 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 2008 | Member Level: Gold | Rating: 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 2008 | Member Level: Silver | Rating: 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; } }
|