Count child nodes

Verified
Added by iNTERFACEWARE

Use node.childCount() to count the number of children for a specified node, works for all node types

Source Code
   -- create sample XML node
   local x = [[
   
      John
      Smith
   ]]
   xmlMsg = xml.parse(x)
   trace(xmlMsg)
   
   -- count child nodes - for patient
   local cnt = xmlMsg.patient:childCount()
   --> 3
Description
Use node.childCount() to count the number of children for a specified node, works for all node types
Usage Details

Use node.childCount() to count the number of children for a specified node.

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

How to use the snippet:

  • Paste the code into your script