php domdocument mendapatkan elemen satu per satu

$array = [];
$i = 1;
foreach($dom->getElementsByTagName('*') as $node)
{
  if( $node->tagName != "html" AND $node->tagName != "body" AND $node->tagName != "br" )
  {
    $array[$i]['type'] = $node->tagName;
    $array[$i]['text'] = trim($node->textContent);
    $i++;
  }
}
sabry suleiman