FromXml Bug - IgnoreUnknownElements also ignores known elements
Problem reported by Irwin Plitt - November 8 at 9:09 PM
FromXml does not work properly when the SerializationContext.IgnoreUnknownElements option is used.

Specifically, when an unknown element is present and it precedes two or more optional elements, the first optional element is also ignored.

The car.xsd is defined as:
  <xs:element name="Car">
        <xs:element name="Make" type="xs:string" />
        <xs:element name="Color" type="xs:string" minOccurs="0" />
        <xs:element name="Owner" type="xs:string" minOccurs="0" />

This is the xml sent to the FromXml method:


After using the FromXml method and specifying IgnoreUnknownElements=true, and then using the ToXml method, the expected result is:


but the actual xml is missing the Color element, the first optional element following the unknown element:


1 Reply

Reply to Thread
Irwin Plitt Replied
I have a demonstration project that illustrates this issue at

Reply to Thread