How to convert Empty String to Null in Data Mapper

For Liquid Data Mapper 2018 and later:
Liquid Data Mapper 2018 contains an Empty To Null component as standard, please see the online documentation:
For Liquid Data Mapper 2017
If you have a data input value which is an empty string, when this is mapped to an output xml node the node will be written out with an empty value. However, sometimes this is not the required functionality as you may wish to omit the node in the output xml document. This is exactly what happens for Null values.
In order to convert an empty string to a Null value, you can use a Sub Function.
Note: You can create a Sub Function by opening a Data Mapper (.dm) file, highlighting the items you want to be included in the sub function, right click menu -> Create Function. The sub function will be added to the current project and is shown in the Component Palette window. This can then be dragged onto any Data Mapper file which is included in the project.
Download Zip file containing the EmptyToNull.dmf file:
Here is what the Sub Function looks like:
You would add EmptyToNull.dmf file to your project:
In the Component Pallet you would then see:
And when you dragged the EmptyToNull onto the Data Mapper, you would use it like so: