Here is an example I posted on Friday that illustrates this.
http://www.winisp.net/cheeso/srcview...ateOptional.cs
For more background on this, search for the thread entitled "XmlSerializer
for optional xs:date", starting 21 July 2004.
For the doc on this, see
http://msdn.microsoft.com/library/en...ClassTopic.asp
and look for the discussion on propertyNameSpecified .
-Dino
"raffelm" <ma*********@mindspring.com> wrote in message
news:ba**************************@posting.google.c om...
I have a class with a property is set to export as an XmlAttribute. I
want the attribute to only be written if there is a value. Is that
possible? Right now, the attribute is written no matter what.
eg:
[XmlRoot("Server")]
class Server
{
[XmlAttribute("shareName")]
public string ShareName
{
get {return shareName;}
set {shareName = value; shareNameChanged = true;}
}
}
Thanks
Matt