XML Serialization Using XMLElement

bhluth6tit

New Member
I have a defined class that has the following data\[code\]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; } }}\[/code\]Then I populate this using a set of data I get so I have no predefined fields and on serialize the results is as follows\[code\]<FieldNode> <FieldName FieldID="LastName" FieldRights="true"> <FieldValue>Harris</FieldValue> </FieldName> <FieldName FieldID="FirstNameName" FieldRights="true"> <FieldValue>John</FieldValue> </FieldName></FieldNode>\[/code\]Now, Is there a way that serialization takes the value of FieldID and replace FieldName with it to get the following\[code\]<FieldNode> <LastName FieldID="LastName" FieldRights="true"> <FieldValue>Harris</FieldValue> </LastName > <FirstName FieldID="FirstName" FieldRights="true"> <FieldValue>John</FieldValue> </FirstName></FieldNode>\[/code\]
 
Back
Top