I'm not able to remove the name of the Attribute Values in clsProduct from my xml. I tried using [XmlElement(ElementName = "Values", Type = typeof(clsValues)] for my List<clsValues> but it didn't give me the result I need.
You can see the result I need below.
Parts of my serialization class:
[Serializable]
public class clsProduct
{
[XmlAttribute("ID")]
public string ID { get; set; }
[XmlAttribute("UserTypeID")]
public string UserTypeID { get; set; }
[XmlArrayItem(ElementName = "Values", Type = typeof(clsValues))]
public List<clsValues> Values { get; set; }
}
[Serializable]
public class clsValues
{
[XmlElement(ElementName = "Value")]
public clsValue Value { get; set; }
[XmlArray(ElementName = "MultiValue"),
XmlArrayItem(ElementName = "Value")]
public List<clsValue> MultiValue { get; set; }
}
[Serializable]
public class clsValue
{
[XmlAttribute("AttributeID")]
public string AttributeID { get; set; }
[XmlText]
public string Value { get; set; }
}
My current xml result:
<Product ID="PROD-01111010" UserTypeID="Product">
<Values>
<Values>
<Value AttributeID="ATTR-7196">201607280755</Value>
</Values>
<Values>
<Value AttributeID="ATTR-6236">PTFE 125 + 25% GF, Platte</Value>
</Values>
<Values>
<MultiValue>
<Value>PLATTE</Value>
<Value>LUBRIFLON 225</Value>
<Value>PLAQUE</Value>
<Value>LUBRIFLON 22</Value>
</MultiValue>
</Values>
</Values>
</Product>
Result I need:
<Product ID="PROD-01111010" UserTypeID="Product">
<Values>
<Value AttributeID="ATTR-7196">201607280755</Value>
<Value AttributeID="ATTR-6236">PTFE 125 + 25% GF, Platte</Value>
<MultiValue>
<Value>PLATTE</Value>
<Value>LUBRIFLON 225</Value>
<Value>PLAQUE</Value>
<Value>LUBRIFLON 22</Value>
</MultiValue>
</Values>
</Product>
Can someone help?
Thanks
Edit: When I'm using
[XmlElement(ElementName = "Values", Type = typeof(clsValues))]
public List<clsValues> Values { get; set; }
instead of XmlArrayItem I get this result:
<Product ID="PROD-01111010" UserTypeID="Product">
<Values>
<Value AttributeID="ATTR-7196">201607280755</Value>
</Values>
<Values>
<Value AttributeID="ATTR-6236">PTFE 125 + 25% GF, Platte</Value>
</Values>
<Values>
<MultiValue>
<Value>PLATTE</Value>
<Value>LUBRIFLON 225</Value>
<Value>PLAQUE</Value>
<Value>LUBRIFLON 22</Value>
</MultiValue>
</Values>
</Product>
clsprefix and start following normal .NET naming conventions.