クライアントスキームと正確に一致する必要がある製品のXMLフィードを作成しています。web apiとモデルバインディングを使用してxml属性を定義する方法
私はWeb 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
/>
[どのように私は、XMLは、MVC Webでアクションモデルに属性を結合しないのが重複する可能性API?](http://stackoverflow.com/questions/10641426/how-do-i-bind-xml-attributes-to-the-action-model-in-mvc-web-api) –
上記の投稿はベータリリースに関連している。私はこれを読んだが、今は当てはまるとは確信していない。私の感情は、明らかに何かが欠けているということです。 – frosty