|
-
May 10th, 2005, 04:52 AM
#1
Thread Starter
Member
serializing empty xml element
Hi,
i am using System.Xml.Serialization;
how can i serialize an empty element output <something /> ?
current, after serialize an empty element, it wont show, only not null element wil be output.
Please advise.
-
May 20th, 2005, 04:42 PM
#2
Hyperactive Member
Re: serializing empty xml element
My first question would be, why do you want to serialize something that does not contain any information? Why not just check on the deserialize side and take action if that object and / or variable is null or empty?
-
May 21st, 2005, 04:32 PM
#3
PowerPoster
Re: serializing empty xml element
You can add an attribute above your property:
<XmlElement(isnullable:=True)>
public string Something;
-
May 25th, 2005, 10:38 PM
#4
Thread Starter
Member
Re: serializing empty xml element
 Originally Posted by Phenglai
My first question would be, why do you want to serialize something that does not contain any information? Why not just check on the deserialize side and take action if that object and / or variable is null or empty?
eg.
<car>
<door>door 1</door>
<door>door 2</door>
<alarm>alarm brand</alarm>
</car>
<car>
<door>door 1</door>
<door>door 2</door>
<alarm/>
</car>
Not every car has alarm but i want to show as an empty tag instead of no tag.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|