Thanks for the info Alex...
xml generation for each and every property of my class....
properties...
properties thru the XmlWriter...
Can I avoid it? Is there any solution for this...
of the properties should be taken care of implicitly... is it possible...
"Alex Meleta" wrote:
>
> The simple way is to use default behavior of the XmlSerializer by defining
> the new method returning something that the XmlSerializer can simply serialize
> be itself:
>
> [XmlRoot("Task")]
> public class CustomSerialization1 : IXmlSerializable
> { ...
>
> [XmlIgnore()]
> public string Test
> {
> ....
> }
>
> [XmlArray("Test")]
> [XmlArrayItem("TestInnner")]
> public string[] TestAsArray
> {
> get { return _s.Split(','); }
> set { _s = string.Join(",", value); }
> }
>
> another (and more complicated approach) is to use the IXmlSerializable interface.
> By overriding ReadXml and WriteXml you can control the Xml serialization
> by yourselves. E.g.
>
> public class CustomSerialization1 : IXmlSerializable
> { .....
> public void WriteXml(XmlWriter writer)
> {
> .....
> writer.WriteStartElement("Test");
> foreach (string s in _s.Split(','))
> {
> writer.WriteElementString("TestInnerValue", s);
> }
> writer.WriteEndElement();
> .....
> }
> ..... }
>
> Alex
>
http://devkids.blogspot.com >
>
>
> > Hi,
> > I'm new serialization concepts....I need some hwlp..
> > I've a class defined as follows
> > class CustomSerialization1
> > {
> > private string s;
> > public string Test
> > {
> > get { return s; }
> > set { s = value; }
> > }
> > private int i;
> >
> > public int Test1
> > {
> > get { return i; }
> > set { i = value; }
> > }
> > CustomSerialization1 obj = new CustomSerialization1();
> > obj.Test = "vijaya,wajid,vani";
> > object.Test1 = 3;
> > }
> > if want the the output to be sth below after applying
> > serializatiion
> >
> > <Task>
> > <Test>
> > <TestInnner>Vijaya</TestInnner>
> > <TestInnner>wajid</TestInnner>
> > <TestInnner>vani</TestInnner>
> > </Test>
> > <Test1>3</Test3>
> > </Task>
> > Basically I want to control teh way inwhich my Test property will be
> > displayed during serialization and deserialization....
> >
> > please help me out..just let me know if this is possible by any
> > means... either thru XmlSerialization or Custom Serialziation...
> >
>
>
>