Fix #54: Check for children before referencing
Check for children of the node before referencing child nodes. If there are no children, the node must only have text so append to the text.