One of the jobs of my program is to read customer list from a xml file and deserialize them into C# class like below:
<?xml version="1.0" encoding="utf-8"?>
<customers>
<customer>
<name>john</name>
<id>1</id>
</customer>
<customer>
<name>mike</name>
<id>2</id>
</customer>
</customers>
C# class:
[XmlRoot("customers")]
public class CustomerList {
[XmlElement("customer")]
public Customer[] Customers { get; set; }
}
public class Customer {
[XmlElement("name")]
public String Name {get; set;}
[XmlElement("id")]
public String Id {get; set;}
}
but recently customer wants to change the tag name from <id>
to <code>
like the one below:
<?xml version="1.0" encoding="utf-8"?>
<customers>
<customer>
<name>john</name>
<code>1</code>
</customer>
<customer>
<name>mike</name>
<code>2</code>
</customer>
</customers>
The value for 'code' will have the same meaning with previous tag 'id'. And they want that during transition the program should be amended so it recognizes both tags for a period of time.
Is there any easy method to achieve that? Thanks.