Append an XML node


This code demonstrates how to use the built-in node.append() to append an XML node to an XML node tree. The node.append() function creates and appends a new node to a specified (parent) XML Node.

Code to Append an XML Node [top]

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

Using the code for Appending an XML node [top]

The code demonstrates how to append a node to an XML node tree.

How to use the code:

  1. Paste the code into the main module of your channel.
  2. Then modify the code to suit your requirements.

More Information [top]


Leave A Comment?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.