0

I found this link How can I ignore unknown enum values during json deserialization? for json deserialization.

is this same possible in xml deserialization?

how can we achieve this by using IXmlSerializable intererface

Smirti
  • 305
  • 2
  • 12
  • Please try `XmlIgnore` http://www.blackwasp.co.uk/XMLIgnore.aspx – Markus Meyer Aug 16 '22 at 06:25
  • I wanted to deserialize the enum values which is available in my enum list. anything which is not identified in my list, that must not be deserialized. XmlIgnore is used to ignore the property to be dederialized – Smirti Aug 16 '22 at 07:56
  • Are you able to set the enum as nullable? `EnumType?`. Unknown mapping will be ignored and set to null. – klekmek Aug 16 '22 at 08:28
  • enum types cannot be nullable – Smirti Aug 16 '22 at 09:13
  • Only public properties in the c# classes get deserialized. So making properties private will ignore values. – jdweng Aug 16 '22 at 09:58
  • 1
    Are you using `XmlSerializer`? If so do [XmlSerializer: How to Deserialize an enum value that no longer exists](https://stackoverflow.com/q/10708240), [How to ignore invalid enum values during xml deserialization?](https://stackoverflow.com/q/59247332), [XmlSerializer with new enum values](https://stackoverflow.com/q/1621306) and [Skipping Invalid Values On Deserialize](https://stackoverflow.com/q/28782773) answer your question? – dbc Aug 16 '22 at 16:51

0 Answers0