Is there any way to deserialize elements containing either simple text or subelement to a string with XmlSerializer?
Xml sample:
<Attribute>
<AttributeValue xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">thisistext</AttributeValue>
<AttributeValue>
<e:Authorities xmlns:e="urn:dummy">
<e:Authority>ORG_CHIEF</esia-encoder:Authority>
</e:Authorities>
</AttributeValue>
</Attribute>
C# property:
[XmlElement("AttributeValue", IsNullable = true)]
public string[] AttributeValue { get; set; }
Deserialization of the first AttributeValue succeed, but the next one fails. No wonder, beacause ReadElementString method expects simple or empty content. I’m looking for a way to tell to serializer “put content of this element to a string, whatever it contains”.
Actually, the 2nd value you have in your XML is:
This is no valid
stringdataType which is expected because of: