I have a WebService that I support while working on .Net 2.0. It uses the original asmx file standard for a series of web services. These web services return some objects that potentially have a large number of null values. For example:
<user id="1" name="foo" job="null" location="null" audience="null" />
This is a simple example; in fact, we have a lot more “null” values. Since I really do not need zeros, because I can easily conclude that they are zero from their nonexistence, I would prefer not to return them at all. It can be done? If so, how?
Edited to add class definition:
[Serializable]
public partial class User
[XmlAttribute("Id")]
public int Id
{
get { return GetColumnValue<int>("ID"); }
set { SetColumnValue("ID", value); }
}
[XmlAttribute("Username")]
public string Username
{
get { return GetColumnValue<string>("Username"); }
set { SetColumnValue("Username", value); }
}
}
By the way, I want to see:
<user id="1" name="foo" />