I want xml with custom name for element atrribute, I declared the name as shown below
[XmlRoot(ElementName = "country")]
public class CountryInRegion
{
[XmlElement(ElementName = "iso_code")]
public string IsoCode { get; set; }
[XmlElement(ElementName = "name")]
public string Name { get; set; }
[XmlElement(ElementName = "region_id")]
public string RegionId { get; set; }
}
[XmlRoot(ElementName = "countries")]
public class Countries
{
[XmlArray(ElementName = "country")]
public IList<CountryInRegion> countries { get; set; }
public Countries()
{
countries = new List<CountryInRegion>();
}
}
and I get the output like this
<Countries>
<countries>
<CountryInRegion>
<IsoCode>AD</IsoCode>
<Name>Andorra</Name>
<RegionId>EUROPE</RegionId></CountryInRegion>
</CountryInRegion>
</countries>
</Countries>
i tried [XmlElement(“name")] as well. but no changes is obtained