Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Want the NULL mapped tag to be missed when generating XML from XSD using serialize Expand / Collapse
Author
Message
Posted Friday, January 11, 2013 12:10 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, July 30, 2014 6:14 AM
Points: 80, Visits: 187
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!!

Post #1405783
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse