XMLAttributeOverrides doesnt work



i want to serialize xml but without some xmlattribute in element(classes) RoomPreference and ProjectRequirement. I follow the msdn tutorial and this doesn't work(adds the day to ouputed xml :{ ):



if(somevalue) {
XmlAttributeOverrides xOver = new XmlAttributeOverrides();
XmlAttributes attrs = new XmlAttributes();

/* we will ignore the day=int attribute */
attrs.XmlIgnore = true;
xOver.Add(typeof(ProjectRequirement), "day", attrs);
xOver.Add(typeof(RoomPreference), "day", attrs);
serializer = new XmlSerializer(typeof(DataClasses.Project), xOver);
}


I also read this: Using XmlAttributeOverrides on Nested Properties but i really like to use xmlattributeoverrides due to simplicity.


No comments:

Post a Comment