Undef in XML

I am writing some code that converts a Perl HASH to XML data. I didn’t know how to write Undef in XML. It seems this is the common way to write this:

empty value:      <string />
undefined value: <string defined=”false” />
normal value:     <string>abc</string>

Because you can have empty keys perhaps “” => undef must be written like this <item key=”” defined=”false” /> ?? This rules out Undef keys but I think I can live with it.


Comments

2 Responses to “Undef in XML”

  1. Theo on November 3rd, 2008 11:41 pm

    Well, although a undef key is possible in Perl, it’s probably not a good idea to use one anyway.

    BTW, that should be (forward slash), not (backslash), right?

  2. Martin on November 4th, 2008 12:00 am

    Yes, I will change the slashes in this post now.