I am having a problem while deserializing an XML:
[XmlRoot("ProductCategory")]
public class ProductCategory
{
public Product[] Products;
}
public class Product
{
[XmlArray("Product")]
[XmlArrayItem("ProductPrice", typeof(ProductPrice))]
public ProductPrice[] Prices;
}
public class ProductPrice
{
[XmlAttribute]
public int Duration;
[XmlAttribute]
public string DurationType;
[XmlAttribute]
public decimal Price;
[XmlAttribute]
public decimal RegularPrice;
[XmlAttribute]
public decimal YourPrice;
[XmlAttribute]
public string CouponPrice;
[XmlAttribute]
public string Currency;
}
and this is the action:
public ProductType GetPricing()
{
XDocument doc = new Query(_params)
.AddParameter("ProductType", "DOMAIN")
.AddParameter("ActionName","REGISTER")
.Execute("namecheap.users.getPricing");
var serializer = new XmlSerializer(typeof(ProductType), _ns.NamespaceName);
using (var reader = doc.Root.Element(_ns + "CommandResponse").Element(_ns + "ProductType").CreateReader())
{
return (ProductType)serializer.Deserialize(reader);
}
}
I am getting this error: NullReferenceException: Object reference not set to an instance of an object.
And here you can find example of the xml: https://www.namecheap.com/support/api/methods/users/get-pricing.aspx
Any ideas?