node:remove() function works with the five writeable node tree types. The sixth node type the DB Node tree is read only and will return a “read only” error when you try to remove a node.
The exact behaviour of the
node:remove() function is customized to suit the type of node tree.
XML node trees [top]
The specified node is simply removed from the tree.
For example if we remove the CIRCUIT element you can see it is deleted from the tree:
(DB) Table node trees [top]
- A specified field or row will be removed from the node tree
- A table will be set to empty when the last row is removed
- A specified table will be set to empty
For example if we remove the Ssn field you can see that it is deleted from the node tree:
Similarly if we remove the second row in the kin table, it is deleted from the node tree:
If we delete the last row in the kin table, the table remains but it is empty:
If we remove the kin table (the second table), it is actually set to empty (all rows are deleted):
HL7 and X12 node trees [top]
The HL7 and X12 node trees need to behave differently to conform to the HL7 standard. When a node is removed it is set to empty (no data) rather than being deleted from the tree.
When we remove the Race field (PID node 10) from an HL7 tree, the field is emptied (but not deleted):
And if we look at the original message and the updated message converted back to text, we see that the Race field is now blank (complies with HL7 standards):
When we remove the NK1 segment it is emptied but not deleted from the node tree:
However the result updated message converted back to text is different, the NK1 segment no longer exists (complies with HL7 standards):