クライアントのスキームと正確に一致する必要がある製品の xml フィードを作成しています。
私はウェブAPIを使用しています。プロパティ extractDate を属性にしたいと思います。次のコードは、属性ではなく要素として extractDate を出力しています
public Feed GetProducts()
{
var feed = new Feed()
{
extractDate = "extractDate",
incremental = true,
name = "name",
Brands = GetBrands(),
Categories = GetCategories(),
Products = GetProducts()
};
return feed;
}
これが私のモデルのフィードです。以下は要素を属性に変えないように見えることに注意してください
[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; }
}
どのように出力するのですか
<feed extractDate="2012/01/01"
// other logic
/>