First you need to use the following xpath query.
$rows = $xpath->query('//table[@id="r"]/tbody[@class="table-text"]/tr');
As your HTML table is not syntax formatted then the following lines will no longer work.
// explode on each newline character in nodeValue (note the HTML tags are stripped out, leaving just the text inside the td tags)
// and merge with the $defaults array
$values = array_replace($defaults, explode("\n", trim($row->nodeValue)));
// remove any whitespace before or after each value
$values = array_map('trim', $values);
Instead replace them with the following
// get the values for the child "td" tags in the row
$values = getChildNodeValues($row->childNodes, 'td');
And add the following function before the foreach loop
function getChildNodeValues(&$nodeList, $nodeName)
{
$values = array();
foreach($nodeList as $node)
{
if($node->nodeName == $nodeName)
$values[] = trim($node->nodeValue);
}
return $values;
}