src/Document/AbstractNode.php
protected function setScalarNodeCdata($name, $value)
    {
        // get tag
        $childDomElement = $this->getDomElement()->getElementsByTagName($name)->item(0);
        if ($childDomElement === null) {
            $childDomElement = $this->getDomElement()->ownerDocument->createElement($name);
            $this->getDomElement()->appendChild($childDomElement);
        }

        // upsert cdata
        $cdata = $this->getDomElement()->ownerDocument->createCDATASection($value);
        if ($childDomElement->hasChildNodes()) {
            // update cdata
            $childDomElement->replaceChild($cdata, $childDomElement->firstChild);
        } else {
            // insert cdata
            $childDomElement->appendChild($cdata);
        }

        return $this;
    }
protected function setScalarNodeCdata($name, $value)
    {
        // get tag
        $childDomElement = $this->getDomElement()->getElementsByTagName($name)->item(0);
        if ($childDomElement === null) {
            $childDomElement = $this->getDomElement()->ownerDocument->createElement($name);
            $this->getDomElement()->appendChild($childDomElement);
        }

        // upsert cdata
        $cdata = $this->getDomElement()->ownerDocument->createCDATASection($value);
        if ($childDomElement->hasChildNodes()) {
            // update cdata
            $childDomElement->replaceChild($cdata, $childDomElement->firstChild);
        } else {
            // insert cdata
            $childDomElement->appendChild($cdata);
        }

        return $this;
    }
protected function setScalarNodeCdata ( $ name , $ value ) { // get tag $ childDomElement = $ this -> getDomElement ( ) -> getElementsByTagName ( $ name ) -> item ( 0 ) ; if ( $ childDomElement === null ) { $ childDomElement = $ this -> getDomElement ( ) -> ownerDocument -> createElement ( $ name ) ; $ this -> getDomElement ( ) -> appendChild ( $ childDomElement ) ; } // upsert cdata $ cdata = $ this -> getDomElement ( ) -> ownerDocument -> createCDATASection ( $ value ) ; if ( $ childDomElement -> hasChildNodes ( ) ) { // update cdata $ childDomElement -> replaceChild ( $ cdata , $ childDomElement -> firstChild ) ; } else { // insert cdata $ childDomElement -> appendChild ( $ cdata ) ; } return $ this ; }
Set cdata for given child node or create new child node

@param string $name name of node
@param string $value value of cdata

@return $this
Set cdata for given child node or create new child node