Hi,
I've got two classes - Entity which will have an array of Child objects
in it and Child class.
class Entity
{
public Child[] Children;
}
class Child
{
public string Name;
public string Description;
}
I want to be able to serialize this class into two different XMLs.
1) looks like,
<Entity>
<Child Name="" Description=""/>
<Child Name="" Description=""/>
<Child Name="" Description=""/>
</Entity>
2) looks like,
<Entity>
<Child Name=""/>
<Child Name=""/>
<Child Name=""/>
</Entity>
How to do this? Coz If I use [XmlIgnore] attribute on class Child's
description attribute, then it won't allow me to produce Xml (1).
So its basically to control serialization during runtime.
My serialization code currently looks like,
// Serialize the Entity object in to an XML document, and we are done.
TextWriter objTextWriter = null;
XmlSerializer objXmlSerializer = new
XmlSerializer(typeof(Entity));
objTextWriter = new StreamWriter(@"C:\Entity.xml");
objXmlSerializer.Serialize(objTextWriter, objEntity);
Any help in this regard would be of great help. MS experts help me out
here... please..
Cheers,
Vin