Given the following code…
[XmlType("Field")]
public class SearchField
{
[XmlAttribute("alias")]
public string Alias;
[XmlAttribute("entity")]
public string Entity;
}
Alias is an optional field for us, but the deserializer throws when the “alias” attribute is missing from the xml. How do you make it optional? Is a schema required?
Weird, because the following program works fine for me, without any throwings:
As you can see the
aliasattribute is omitted from the input XML and yet no problem deserializing.