Click here to Skip to main content
15,916,188 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Dear Friends Here i want to know how to insert null values in xml,Datatype is ineger.If it is string not a problem.But while comes to interger the xml schema not returning null values

Example:


table
empid>423 coursename>Diploma In Political Software Management <subjectname>Political Science,SharePoint,Super Subject,Power Subject
duration>2 status>Not Completed

But now i want xml should be


HTML
<table>
    empid />
    coursename>Diploma In Political Software Management
    subjectname>Political Science,SharePoint,Super Subject,Power Subject
    uration>2
    tatus>Not Completed
 </table>


That emp id should display empty

please rectify it......
Posted
Updated 24-Apr-12 12:51pm
v3
Comments
El_Codero 24-Apr-12 18:54pm    
if your xml should be like in your example, you're doing something wrong.
What you've tried so far to create your XML, please provide code.Regards
Sergey Alexandrovich Kryukov 25-Apr-12 0:43am    
In other words, this is not a XML at all.
However, the question is interesting enough; I've answered it -- please see.
--SA
Sergey Alexandrovich Kryukov 25-Apr-12 0:45am    
Probably this wrong XML code is just because of bad HTML. OP needs to escape <> with HTML entities: &lt;&gt;…
--SA

1 solution

You can invent any custom ways of representing null, but there is a standard way. It is described with this schema:
http://www.w3.org/2001/XMLSchema-instance[^].

Please take a look. Basically, it describes just 4 attributes: "type", noNamespaceSchemaLocation, "schemaLocation" and "noNamespaceSchemaLocation".

You should use i:nil="true" to express null (where i is some namespace prefix referencing the namespace shown above, it can be any unique valid identifier).

For some example of the usage, you can see how Data Contract works, more exactly System.Runtime.Serialization.DataContractSerializer. It can serialize any object graph defined by a contract, with any members including null; and the null is expressed as I've shown above. You can try using it to see how it works. Please see:
http://msdn.microsoft.com/en-us/library/ms733127.aspx[^],
http://msdn.microsoft.com/en-us/library/system.runtime.serialization.datacontractserializer.aspx[^].

—SA
 
Share this answer
 
v2
Comments
VJ Reddy 25-Apr-12 1:32am    
Good answer and good references. 5!
Sergey Alexandrovich Kryukov 25-Apr-12 10:38am    
Thank you, VJ.
--SA
Anil Honey 206 25-Apr-12 3:12am    
Thank You for giving valuable information
Sergey Alexandrovich Kryukov 25-Apr-12 10:38am    
You are very welcome.
Good luck, call again.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900