我正在尝试将具有原始类型和复杂对象的对象序列化为用于对象的XML
格式XMLArrays
。我遇到了困难,因为我需要按特定顺序对每个 XML 元素进行排序,但我收到以下错误消息:
"XmlElement, XmlText, and XmlAnyElement cannot be used in conjunction with XmlAttribute, XmlAnyAttribute, XmlArray, or XmlArrayItem."
这是我的代码:
public class XMLClaimFieldInfo
{
[XmlIgnore]
public int SectionID { get; set; }
[XmlElement(Order = 1)]
public string Name { get; set; }
[XmlElement(Order = 2)]
public string ClaimDataType { get; set; }
[XmlElement(Order = 3)]
public int UIGridRowLoc { get; set; }
[XmlElement(Order = 4)]
public int UIGridColLoc { get; set; }
[XmlElement(Order = 5)]
public int TabOrder { get; set; }
[XmlElement(Order = 6)]
public string DefaultValue { get; set; }
[XmlElement(Order = 7)]
public int? UIGridRowSpan { get; set; }
[XmlElement(Order = 8)]
public int? UIGridColSpan { get; set; }
[XmlElement(Order = 9)]
public string Format { get; set; }
[XmlElement(Order = 10)]
public bool IsHidden { get; set; }
[XmlElement(Order = 11)]
[XmlArrayItem("XMLClaimFieldSelectOption")]
public List<XMLClaimFieldSelectOption> ClaimFieldSelectOptions;
[XmlElement(Order = 12)]
[XmlArrayItem("XMLFieldValidation")]
public List<XMLFieldValidation> FieldValidations { get; set; }
[XmlElement(Order = 13)]
[XmlArrayItem("XMLClaimFieldObjectMap")]
public List<XMLClaimFieldObjectMap> ClaimFieldObjectMaps = new List<XMLClaimFieldObjectMap>();
我猜这是因为我将XMLElement
属性与属性一起使用XMLArrayItem
?有没有办法解决?