When I serialize class object into xml. Properties get saved but not their Attributes. Is there any way we can serialize/de-serialize their attributes as well
Following is example:
[Category("Invoice Fare(Selling Price) / Client Fare PP")]
[Description("Client Tax / Tax PP")]
[DisplayName("Client Tax / Tax PP")]
[Browsable(true)]
[RadSortOrder(5)]
public string clientTax { get; set; }
like above example could be like below
<clientTax Category='xxx' Description='aaa'></clientTax>
To serialize to XML attributes, you will need to make a class where properties will be the XML attributes decorated with the [XmlAttribute]
annotation.
To reproduce your exemple, it would look like this :
public class ClientTax
{
[XmlAttribute]
public string Category { get; set; }
[XmlAttribute]
public string Description { get; set; }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.