Question: Deserializing with unknown content
See original GitHub issueAfter reading the wiki at: https://github.com/ExtendedXmlSerializer/home/wiki/Example-Scenarios#unknown-content
It does not look like it is working correctly for me.
I was testing the WithUnknownContent() option because an xml document changed and some fields are now deprecated. Hopefully this can easily solve the problem without using Xslt.
But before I got there I noticed something strange with WithUnknownContent() when trying it out on an xml file without any unknown content.
var configurationContainer = new ConfigurationContainer()
.EnableImplicitTyping(typeof(InputModel))
.Create();
var inputModel = configurationContainer.Deserialize<InputModel>(new XmlReaderSettings { IgnoreWhitespace = false }, inputXml);
var configurationContainer2 = new ConfigurationContainer()
.EnableImplicitTyping(typeof(InputModel))
.WithUnknownContent()
.Continue()
.Create();
var inputModel2 = configurationContainer2.Deserialize<InputModel>(new XmlReaderSettings { IgnoreWhitespace = false }, inputXml);
I tried the above configurationContainers to deserialize an xml file without unknown content but noticed the deserialization no longer works when I add WithUnknownContent(). For var inputModel the deserialization works. For var inputModel2 the deserialization does not work.
Any idea why the deserialization stops working when I add WithUnknownContent?
Let me know if you need the InputModel class or an example XML file.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
Just tested WithUnknownContent with some deprecated properties in my xml files, works perfect. Deprecated properties are ignored and next elements are added without any problem!
Thanks again, that answers my question.