src/Lib/XmlTool.php
public static function setNodeText($dom_document, $node, $text)
    {
       /*
        * Clear existing child nodes
        */
        foreach($node->childNodes as $child_node)
        {
            $node->removeChild($child_node);
        }

       /*
        * Add a new child TextNode
        */
        return $node->appendChild($dom_document->createTextNode($text));
    }
public static function setNodeText($dom_document, $node, $text)
    {
       /*
        * Clear existing child nodes
        */
        foreach($node->childNodes as $child_node)
        {
            $node->removeChild($child_node);
        }

       /*
        * Add a new child TextNode
        */
        return $node->appendChild($dom_document->createTextNode($text));
    }
public static function setNodeText ( $ dom_document , $ node , $ text ) { /*
        * Clear existing child nodes
        */ foreach ( $ node -> childNodes as $ child_node ) { $ node -> removeChild ( $ child_node ) ; } /*
        * Add a new child TextNode
        */ return $ node -> appendChild ( $ dom_document -> createTextNode ( $ text ) ) ; }
Replace the content of a node by a TextNode containing the given text

Note:
compared to using $node->nodeValue, this method automatically encodes the text
to support characters such as ampersand

@param DOMDocument $dom_document
@param DOMNode $node
@param string $text
@return DOMNode the newly created TextNode
Replace the content of a node by a TextNode containing the given text