I have something like the following xml that I need to deserialize (note I cannot change the XML):
<Root>
<Products>
<Product>1</Product>
<Product>2</Product>
<Product>3</Product>
</Products>
</Root>
Here is how I am trying to deserialize it:
[XmlRoot("Root")]
public class ProductsResponse
{
[XmlElement("Products", typeof(MyProduct[]))]
public MyProduct[] Products;
}
The problem is that it will not deserialize because when it gets to Product, it compares that element name to the type of my array, which is MyProduct. Is there any way I can deserialze into a class that is not named Product? I would like to avoid renaming my MyProduct class if possible.