I have two serializable objects:
[Serializable]
public class A
{
[XmlArray("Items")]
[XmlArrayItem]
public UnitItem[] Items{get;set;}
......
}
[Serializable]
public class UnitItem
{
[XmlAttribute]
public string Name { get; set; }
[XmlText]
public string Data { get; set; }
}
I can serialize A like:
<Items>
<UnitItem Name="AAA">balabala</UnitItem>
<UnitItem Name="BBB">bulubulu</UnitItem>
......
</Items>
but now I want to create a XML structure as follows:
<Items>
<AAA>balabala</AAA>
<BBB>bulubulu</BBB>
......
</Items>
that is to say i expected the ElementName
of XmlArrayItem
is member variable's value not variable's name. How can i do ?
If i have to inherit ISerializable
could you tell me how to implement it?