Note that even though getElementsByTagName returns a NodeList which is defined as a list of DOMNodes, you're actually getting a list of DOMElements. That allows to call getElementsByTagName on each of the results.
$tables = $doc->getElementsByTagName('table');
foreach ($tables as $table) {
$trs = $table->getElementsByTagName('tr');
// etc...
}