我有一个已定义的类,其中包含以下数据
public partial class EHRNodesTesting {
private string fieldID;
private bool fieldRights;
private string fieldName;
[System.Xml.Serialization.XmlAttribute]
public string FieldID
{
get { return this.fieldID; }
set { this.fieldID = value; }
}
[System.Xml.Serialization.XmlAttribute]
public bool FieldRights
{
get { return this.fieldRights; }
set { this.fieldRights = value; }
}
[XmlElement("Value")]
public string FieldValue
{
get { return this.fieldName; }
set { this.fieldName = value; }
}
}
然后我使用我得到的一组数据填充它,所以我没有预定义的字段,并且在序列化时结果如下
<FieldNode>
<FieldName FieldID="LastName" FieldRights="true">
<FieldValue>Harris</FieldValue>
</FieldName>
<FieldName FieldID="FirstNameName" FieldRights="true">
<FieldValue>John</FieldValue>
</FieldName>
</FieldNode>
现在,有没有一种方法可以让序列化获取 FieldID 的值并用它替换 FieldName 以获得以下内容
<FieldNode>
<LastName FieldID="LastName" FieldRights="true">
<FieldValue>Harris</FieldValue>
</LastName >
<FirstName FieldID="FirstName" FieldRights="true">
<FieldValue>John</FieldValue>
</FirstName>
</FieldNode>