SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Want the NULL mapped tag to be missed when generating XML from XSD using serialize


Want the NULL mapped tag to be missed when generating XML from XSD using serialize

Author
Message
namrata.dhanawade-1143388
namrata.dhanawade-1143388
SSC-Enthusiastic
SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)

Group: General Forum Members
Points: 133 Visits: 205
Hi,

I have a certain set of minoccurs = 0 in my XSD.
When mapping data to the class that I created using this XSD, it is found that the database is returning NULL for certain properties.

I do not want these NULL property elements to appear in the XML

Eg:
<xs:element name="MyLevel" minOccurs = "0" type="xs:string"/>
<xs:element name="YourLevel" minOccurs = "0" type="xs:string"/>
<xs:element name="HisLevel" minOccurs = "0" type="xs:string"/>
<xs:element name="HerLevel" minOccurs = "0" type="xs:string"/>

Now if the database returns
MyLevel as "20"
YourLevel as NULL or Empty
HisLevel as "30"
HerLevel as "40"

I would like the XML to look like
<MyLevel>20</MyLevel>
<HisLevel>30</HisLevel>
<HerLevel>40</HerLevel>

But I instead get
<MyLevel>20</MyLevel>
</YourLevel>
<HisLevel>30</HisLevel>
<HerLevel>40</HerLevel>

Is there a certain property or condition that I may be missing? Is it possible to get the result I am looking for without using an if..else condition when mapping my dataset to the XSD object?

HELP!!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search