Set an XML node to a space " " character

Added by iNTERFACEWARE

Demonstrates the best way to set a XML node to a space character, by using setText(' ') from the xml.lua module

Source Code
require 'xml'

function main(Data)
   -- Parse the XML message
   local XML = xml.parse(Data)
   
   -- Setting social-security-no to a string value works as desired
   local SSN = XML.patients.patient["social-security-no"]:setInner('confidential')
   trace(XML)
   
   -- Setting social-security-no to a space does not work as desired
   -- setInner() parses the string and truncates spaces 
   -- it also removes the TEXT element node (beneath social-security-no)
   local SSN = XML.patients.patient["social-security-no"]:setInner(' ')
   trace(XML)
   
   -- RECOMMENDED BEST PRACTICE: use setText(' ')
   -- Setting social-security-no to a space works as desired
   -- setText() sets the TEXT element node to a space (or any string value)
   -- it also appends a TEXT element node when one does not exists
   local SSN = XML.patients.patient["social-security-no"]:setText(' ')
   trace(XML)
end
Description
Demonstrates the best way to set a XML node to a space character, by using setText(' ') from the xml.lua module