Get the type of a node

Verified
Added by iNTERFACEWARE

Use node.nodeType() to get the type of a node, works for all node types

Source Code
   local Msg, Name = hl7.parse{vmd='example/demo.vmd', data=Data}

   -- get the type of a leaf node (surname)
   local name = Msg.PID[5][1][1][1]:nodeType()
   --> 'subsubfield','hl7'

   -- get the type of a non-leaf node (name)
   local name = Msg.PID[5][1][1]:nodeType()
   --> 'subfield','hl7'
Description
Use node.nodeType() to get the type of a node, works for all node types
Usage Details

Use node.nodeType() to get the type of a node.

Note: The node.nodeType() function works with all types of node trees.

How to use the snippet:

  • Paste the code into your script