I have an xml in which one of the elements has an attribute that can be blank.
For e.g.,
<tests>
<test language="">
.....
</test>
</tests>
Now, language is enum type in the classes created from the schema. It works fine if the language is specified, it fails to deserialize if it is blank (as shown in example).
Edit: Code for deserialization:
XmlSerializer xmlserializer = new XmlSerializer(type);
StringReader strreader = new StringReader(stringXML);
Object o = serializer.Deserialize(strreader);
How can I handle this scenario
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…