private function _retrieveNodeText(DOMNode $node, &$text)
    {
        if ($node->nodeType == XML_TEXT_NODE) {
            $text .= $node->nodeValue;
            if(!in_array($node->parentNode->tagName, $this->_inlineTags)) {
                $text .= ' ';
            }
        } else if ($node->nodeType == XML_ELEMENT_NODE  &&  $node->nodeName != 'script') {
            foreach ($node->childNodes as $childNode) {
                $this->_retrieveNodeText($childNode, $text);
            }
        }
    }
private function _retrieveNodeText(DOMNode $node, &$text)
    {
        if ($node->nodeType == XML_TEXT_NODE) {
            $text .= $node->nodeValue;
            if(!in_array($node->parentNode->tagName, $this->_inlineTags)) {
                $text .= ' ';
            }
        } else if ($node->nodeType == XML_ELEMENT_NODE  &&  $node->nodeName != 'script') {
            foreach ($node->childNodes as $childNode) {
                $this->_retrieveNodeText($childNode, $text);
            }
        }
    }
private function _retrieveNodeText ( DOMNode $ node , & $ text ) { if ( $ node -> nodeType == XML_TEXT_NODE ) { $ text .= $ node -> nodeValue ; if ( ! in_array ( $ node -> parentNode -> tagName , $ this -> _inlineTags ) ) { $ text .= ' ' ; } } else if ( $ node -> nodeType == XML_ELEMENT_NODE && $ node -> nodeName != 'script' ) { foreach ( $ node -> childNodes as $ childNode ) { $ this -> _retrieveNodeText ( $ childNode , $ text ) ; } } }
Get node text

We should exclude scripts, which may be not included into comment tags, CDATA sections,

@param DOMNode $node
@param string  &$text
Get node text