How can I serialize this .NET Collection item?
- by Pure.Krome
Hi folks,
I'm trying to xml serialize a POCO view data class into xml. It serializes, but incorrectly generates some xml.
eg. (current result .. not the one I'm after)
<ReviewListViewData>
<reviews>
<review>....</review>
...
</reviews>
</ReviewListViewData>
I'm trying to get (notice how I've removed the bad root node?) ...
<reviews>
<review>....</review>
...
</reviews>
Class is defined as...
public class ReviewListViewData
{
[XmlArray("reviews")]
[XmlArrayItem("review")]
public ReviewViewData[] Reviews { get; set; }
}
and here's a sample way it's called in an ASP.NET MVC ActionMethod :-
var reviewListViewData = GetReviewListViewData(...);
return XmlResult(reviewListViewData); // (XmlResult referenced from MVCContrib).
anyone have any ideas, please?