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