I have a class - say Place
public class Place{
public int id;
public string name;
public string slug;
}
There are other classes like City, State, Country which are derived from Place class.
I get an XML string like this, that has array of cities
<cities>
<City>
<name>
<![CDATA[Mumbai]]>
</name>
<slug>
<![CDATA[mumbai]]>
</slug>
</City>
<City>
<name>
<![CDATA[Thane]]>
</name>
<slug>
<![CDATA[thane]]>
</slug>
</City>
</cities>
I deserialize this string in the city array and send to Angular UI.
On the frontend, there is no use of id field. But since it is part of class, the empty/null id field also gets deserialize. I can remove the id field from the class, but it is used in other functions so I cannot do that. I don't want to use XmlIgnore attribute because some one might have already used this field in other functions.
My question is, is there a way to remove the id field before sending it forward?
return Serializer.DeserializeXml<Cities>(_strCities);