Append an XML node

Added by iNTERFACEWARE

Use node.append() to append a node to an XML node tree

Source Code
   -- create sample XML node
   local x = [[
      <patient>
         <first-name>John</first-name>
         <last-name>Smith</last-name>
      </patient>]]
   xmlMsg = xml.parse(x)
   trace(xmlMsg)
   
   -- append an ATTRIBUTE
   xmlMsg.patient:append(xml.ATTRIBUTE, 'id')
   trace(xmlMsg)
   
   -- append an ELEMENT
   xmlMsg.patient:append(xml.ELEMENT, 'middle-name')
   trace(xmlMsg)
   
   -- append a TEXT element
   xmlMsg.patient:append(xml.TEXT, 'This is a text comment')
   trace(xmlMsg)
   
   -- append a CDATA (unparsed text) element
   xmlMsg.patient:append(xml.CDATA, 'Because CDATA is not parsed it allows & and <>')
   trace(xmlMsg)