file.html
<div>
<a href="">apple</a>
</div>
$html = new DOMDocument();
$html->preserveWhiteSpace = true;
$html->loadHTML( file_get_contents('file.html') );
$nodes = $html->getElementsByTagName('*');
foreach($nodes as $i=>$node) {
if($node->nodeName == 'div')
echo $node->nodeValue;
}
this returns 'apple'. How do I get the child node including the child node's value, as in:
<a href="#">apple</a>