How To Fetch The InnerHTML Code From HTML Table Using PHP
I am able to parse HTML page properly, but it is parsing just the data whereas I want to fetch entire HTML code inside in , . Below is my PHP code:
Solution 1:
in your second for loop:
foreach ($rows as $row)
{
// get each column by tag name
$cols = $row->getElementsByTagName('td');
$row = array();
$i=0;
foreach ($cols as $node) {
# code...
if($row_headers==NULL)
$row[] = $node->nodeValue;
else
$row[$row_headers[$i]] = $node->firstChild->ownerDocument->saveHTML($node->firstChild);
$i++;
}
$table[] = $row;
}
than the output will be:
[1] => Array
(
[Column 1] => <b>Q</b>
[Column 2] => Desc.
)
Post a Comment for "How To Fetch The InnerHTML Code From HTML Table Using PHP"