I've got some XML I'm working with that returns an array of objects, but at the very top of the array there is a couple of disconnected objects that contain information if the request was valid, how many results there is, etc. My problem is that I can't figure out how to deserialize those objects into the properties I need. Here's the XML and the code I've got so far:
XML
<ItemSearchResponse>
<Items>
<Request>
<IsValid>True</IsValid>
</Request>
<TotalResults>90</TotalResults>
<TotalPages>9</TotalPages>
<Item />
...
</Items>
</ItemSearchResponse>
C#
public class Response {
[XmlArray(ElementName = "Items")]
public Item[] Items { get; set; }
public bool IsValid { get; set; }
public int TotalResults { get; set; }
public int TotalPages { get; set; }
}
As you can see in my code, I'm trying to pull individual objects out and apply them as properties to my Response
object because I think it makes more sense if they sit there. So, how do I take the ItemSearchResponse.Items.Request.IsValid
and turn it into Response.IsValid
? Same question for the TotalResults
and TotalPages
properties?