- var_dump: documentation ( source)
- range: documentation ( source)
<?php
$dom=new DOMDocument;
$dom->loadHTML(<<<HTML
<div>
<a>abc</a>
xyz
</div>
HTML
);
$div=$dom->getElementsByTagName("div")->item(0);
var_dump($div->childNodes->length);//just to debug
$txt="";
foreach(range(0,$div->childNodes->length-1) as $idx)
{
if($div->childNodes->item($idx)->nodeType==3)
{
$txt.=$div->childNodes->item($idx)->nodeValue;
}
}
var_dump($txt);