Append an XML node
Verified
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)
Description
Use node.append() to append a node to an XML node tree
Usage Details
Use node.append()
to append a new XML node to an XML node tree. The code shows how to append the four different types of XML nodes. There are a few tricks to learn with XML node trees, so be sure to look the “more info” links below.
Note: The node.append()
function only works with XML node trees.
How to use the snippet:
- Paste the desired append code into your script