i have this error:
Error Trying to get property of non-object
and the code is:
$dom->preserveWhiteSpace = false;
$tables = $dom->getElementsByTagName('table');
$rows = $tables->item(0)->getElementsByTagName('tr');
$i=0;
foreach ($rows as $row)
{
/*** get each column by tag name ***/
$cols = $row->getElementsByTagName('td');
$this->data['Table'][$i] = array(
'Attrb1' => $cols->item(0)->nodeValue,
'Attrib2' => $cols->item(1)->nodeValue
);
$i++;
}
}
return $this->toArray();
}
The line that i have this error is :
'Attrib2' => $cols->item(1)->nodeValue
the html code is:
<table border=1 align="center" cellpadding=5 width="95%">
<!doctype html public "-//w3c//dtd html 4.0//EN">
<html it>
<head>
<meta name="Generator" content="OLS">
</head>
<body>
<td colspan=2 align="center">
<b>
<i>
Attrib1
</i>
</b>
</td>
<td>
<b>
<i>
Attrib2
</i>
</b>
</td>
<td>
<b>
<i>
<tr>
<td>
A000211
</td>
<td nowrap>
Statistic
</td>
</tr>
but i don't know if the problem is in the foreach or all get data that i make is one big error or i process the html in a wrong way..so help me please..