I am somehow not able to achieve this serialization. I have these classes
public class Data
{
[XmlElement("Name")]
public string Name { get; set; }
}
[XmlRoot("Data")]
public class DataA : Data
{
[XmlElement("ADesc")]
public string ADesc { get; set; }
}
[XmlRoot("Data")]
public class DataB : Data
{
[XmlElement("BDesc")]
public string BDesc { get; set; }
}
When I serialize either DataA or DataB I should get the XMLs in the below structure:
<Data xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="" i:type="DataA">
<Name>A1</Name>
<ADesc>Description for A</ADesc>
</Data>
<Data xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="" i:type="DataB">
<Name>B1</Name>
<BDesc>Description for b</BDesc>
</Data>
What I am getting is the below (without the i:type="..." and xmlns="")
<Data xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Name>A1</Name>
<ADesc>Description for A</ADesc>
</Data>
<Data xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Name>B1</Name>
<BDesc>Description for b</BDesc>
</Data>
I am not sure what I am missing here. any suggestions would be helpful.
- Girija