Search code examples
phpzend-dom-query

Zend_Dom_Query how to get html code of current node


I have nodes, and iterate them in loop.

$html = <<<HTML
    <div id="test">
    <span>1</span>
    <span>2</span>
    </div>
HTML;
$dom= new Zend_Dom_Query($html);
$results = $dom->query('span');
foreach($results as $node){
...
}

How get html code of node? (not innerHTML, full HTML code <span>1</span>)


Solution

  • $htmlNode = iconv('UTF-8','ISO-8859-1',$results->getDocument()->saveXML($node));
    

    Iconv exist here because i have russian characters.