hide empty variables in ASP.NET webservice XML

clear90

New Member
I've an ASP.NET webservice which has this class\[code\] public class Contact { public int type; public string data; }\[/code\]the problem is that sometimes the "type" variable has no data, so by default it will be considered 0 and will return 0 in the XML as shown:\[code\]<Contact> <type>0</type> <data>Hello</data></Contact>\[/code\]how can i avoid returning the "type" variable when it's 0 so that i can get the following output:\[code\]<Contact> <data>Hello</data></Contact>\[/code\]Note: if a changed the type to be a string then the problem is solved, but i have other classes and i have to set the type of their variables. so this solution is not going to work.any idea?thanks
 
Back
Top