Deserialize Xml with empty elements in C#
- by user204086
Trying to deserialize some xml snippits into objects. The problem is that I'm getting an invalid format on every empy element tag. I can deserialize the object no problem when all of the elements have values. Or the empty elements are ommitted.
Xml Snippit:
<foo><propOne>1</propOne><propTwo /></foo>
C# Class:
[Serialilbe()]
public class foo
{
public foo(){}
[XmlElementAttribute(IsNullable = true)]
public int? propOne {get;set;}
[XmlElementAttribute(IsNullable = true)]
public int? propTwo {get;set;}
}
Is there a setting on the class I can make to adjust the parsing?
or
Is there an easy way I can apply xsl to remove these elements?
or
Should I use regEx to remove the empty elements be fore desrializing?
or
an even better way?