Representing Null vs. EmptyString in XML

J

James

In certain applications, it is necessary to distinguish between an
emptyString vs. a null value. What is the appropriate way to make
this distinction in XML?

<elementName></elementName>
looks like a zero-length string (emptyString) but will evaluate to
null.

The data element in question may have its own datatype (string, title,
name, etc.) but also need to hold an emptyString value.
 
R

Richard Tobin

James said:
In certain applications, it is necessary to distinguish between an
emptyString vs. a null value. What is the appropriate way to make
this distinction in XML?

There isn't a way to do this defined in plain XML, but you can make up
your own way of doing it. A natural way is to use an attribute, and
if you're using XML Schema then it provides one: xsi:nil="true" (where
xsi is bound to the schema instance namespace). Nothing stops you
from using this even when you're not using XML Schema, though you will
have to interpret it yourself in the application.

-- Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top