I have a simple class I'm serializing.
[DataContract(Name = "Test", Namespace = "")]
public class Test
{
[DataMember(Order = 0, Name = "Text")]
public string Text { get; set; }
public Test() {}
}
This kicks out the following XML:
<Test>
<Text>Text here</Text>
</Test>
What I want is:
<Test>
<Text type="MyType">Text here</Text>
</Test>
How do I add attributes the the XML elements?
Thanks in advance.
You can't add attributes to a DataContract. You either have to use a class that Implements ISerializable or use the .Net XmlSerializer.