simple_html_dom_node::innertext PHP Method

innertext() public method

get dom node's inner html
public innertext ( )
    function innertext()
    {
        if (isset($this->_[HDOM_INFO_INNER])) {
            return $this->_[HDOM_INFO_INNER];
        }
        if (isset($this->_[HDOM_INFO_TEXT])) {
            return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
        }
        $ret = '';
        foreach ($this->nodes as $n) {
            $ret .= $n->outertext();
        }
        return $ret;
    }

Usage Example

/**
 * @param simple_html_dom_node $child
 * @param string $tmpBuffer
 * @return string
 */
function elementHandler($child, $tmpBuffer, $depth = 0, $break = true)
{
    //foreach ($childsHtml->children as $child) {
    /** @var simple_html_dom_node $child */
    if ($child->tag == 'ul') {
        foreach ($child->children as $grandchild) {
            $tmpBuffer = elementHandler($grandchild, $tmpBuffer, $depth + 1);
        }
        return $tmpBuffer;
    }
    $inner = $child->innertext();
    $break2 = true;
    if ($child->tag == 'li') {
        //$tmpBuffer.='*';
        for ($i = 0; $i < $depth; $i++) {
            $tmpBuffer .= '*';
        }
        if ($inner == '') {
            $break2 = false;
        } else {
            $tmpBuffer .= $inner;
        }
    } else {
        if ($child->tag == 'p') {
            $inner = str_replace("\t", '', $inner);
            $inner = str_replace("\n", ' ', $inner);
            //$tmpBuffer .= $inner;
            $tmpBuffer = depthTest($inner, $child, $tmpBuffer);
        } else {
            if ($child->tag == 'b') {
                $tmpBuffer .= '===';
                $tmpBuffer = depthTest($inner, $child, $tmpBuffer);
                //$tmpBuffer .= $inner;
                $tmpBuffer .= "===";
            } else {
                if ($child->tag == 'u') {
                    $tmpBuffer .= '<u>';
                    $tmpBuffer = depthTest($inner, $child, $tmpBuffer);
                    //$tmpBuffer .= $inner;
                    $tmpBuffer .= '</u>';
                } else {
                    if ($child->tag == 'i') {
                        $tmpBuffer .= '\'\'';
                        $tmpBuffer = depthTest($inner, $child, $tmpBuffer);
                        //$tmpBuffer .= $inner;
                        $tmpBuffer .= '\'\'';
                    } else {
                        if ($child->tag == 'text') {
                            $tmpBuffer .= $inner;
                        } else {
                            if ($child->tag == 'font') {
                                $tmpBuffer .= $inner;
                            }
                        }
                    }
                }
            }
        }
    }
    if ($break && $break2) {
        $tmpBuffer .= "\n";
    }
    //}
    return $tmpBuffer;
}
All Usage Examples Of simple_html_dom_node::innertext