What does i:nil="true" mean?

XmlNullXml Nil

Xml Problem Overview


I have an xml and it has nodes with i:nil="true" in it. What does that mean?

For example:

<FirstName i:nil="true" />

Does that mean something different than:

<FirstName />

If so, what is the difference?

Xml Solutions


Solution 1 - Xml

This means FirstName is null

<FirstName i:nil="true" />

This means FirstName = ""

<FirstName />

Assumption made on FirstName is of string type.

Solution 2 - Xml

Maybe i:nil actually means xsi:nil, this means that the FirstName element is empty, i.e. does not have any content -- not even "". It refers to the nillable property in XML Schema.

Solution 3 - Xml

nil is an attribute, defined in the i namespace. For this FirstName node, the attribute has the value true.

It's similar to this, just with different names and values:

<form name="test">...

Here, form is the name of the node, similar to FirstName from your code, and name is an attribute with a value of "test", similar to your attribute nil with a value of "true".

What this means depends on the application reading the xml document.

If I were to venture a guess, I'd say that this looks like part of a xml document defining some kind of schema, and that the FirstName field can have a NULL or nil value, meaning empty, or unknown.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestiondtcView Question on Stackoverflow
Solution 1 - XmlRay LuView Answer on Stackoverflow
Solution 2 - XmlTorsten MarekView Answer on Stackoverflow
Solution 3 - XmlLasse V. KarlsenView Answer on Stackoverflow