$parentnode = $node -> parentNode; $txtnode = XML::LibXML::Text ->new($tmtext); $node = $parentnode -> replaceChild($txtnode, $node);