sub _addNode { my ($parent, $child) = @_; if(ref($child) eq 'XML::LibXML::Element'){ $parent->appendChild($child); }elsif(ref($child) eq ''){ $parent->appendTextNode($child); }else{ die "'_addNode child is type: ".ref($child). " Do not know what to do with that"; } return $parent; }