Serializing XML with data identified by atributes

simonhind

New Member
Using C# I am trying to serialize an XML containing data within 'field' elements identified by id attributes:\[code\]<data> <row> <field id="firstName">Stef</field> <field id="lastName">Ben</field> <field id="city">LA</field> <field id="state">CA</field> </row> <row> <field id="firstName">Ann</field> <field id="lastName">Brown</field> <field id="city">NY</field> <field id="state">NY</field> </row></data>\[/code\]My goal is to create a class looking like this:\[code\]class User{ private string firstName; [XmlElement("firstName")] public string FirstName { get; set; } [XmlElement("lastName")] public string LastName { get; set; } [XmlElement("city")] public string City { get; set; } [XmlElement("state")] public string State { get; set; }}\[/code\]Do you have any ideas how to serialize and deserialize this XML to achieve this?
 
Back
Top