Delete a node tree element

Verified
Added by iNTERFACEWARE

Use node.remove() to delete an element from a table,

Source Code
   -- node.remove() works on any node tree
   -- an HL7 node tree is used to demonstrate

   local Msg, Name = hl7.parse{vmd='example/demo.vmd', data=Data}
   local Out = hl7.message{vmd='example/demo.vmd', name=Name}
   
   Out:mapTree(Msg)
   
   -- delete a specified node - "OBX" for example
   local deleted = Out:remove('OBX')
   trace(Out)
   trace(deleted)
Description
Use node.remove() to delete an element from a table,
Usage Details

Use node.remove() to delete an element from a node tree. We use an HL7 node tree as an example, but the function works for all node trees.

How to use the snippet:

  • Paste the code into your script

Note: You may also want to look at the table.remove() function to delete elements from Lua tables.