I am creating a product XML file that should exactly match the client schema.
I am using web api. I would like the extractDate property to be an attribute. The following code displays extractDate as an element, not an attribute
public Feed GetProducts() { var feed = new Feed() { extractDate = "extractDate", incremental = true, name = "name", Brands = GetBrands(), Categories = GetCategories(), Products = GetProducts() }; return feed; }
Here is my Feed model. Note that the following does not seem to turn the element into an attribute
[XmlAttribute(AttributeName = "extractDate")] public class Feed { [XmlAttribute(AttributeName = "extractDate")] //attribute is ignored public string extractDate { get; set; } public bool incremental { get; set; } public string name { get; set; } public List<Brand> Brands { get; set; } public List<Category> Categories { get; set; } public List<Product> Products { get; set; } }
How to withdraw
<feed extractDate="2012/01/01"
source share