How to extract data from HTML table in PHP. The data is in this format
Table 1
<tr><td class="body" valign="top"><a href="example"><b>DATA</b></a></td><td class="body" valign="top">Data_Text</td></tr>
Table 2
<tr><th><div id="Data">Data</div></th><td>Data_Text_1</td><td>Data_Text_2</td></tr>
Table 3
<tr><td width="120"><a href="example" target="_blank">DATA</a></td><td>Data_Text</td></tr>
I want to get the Data & Data_Text or (Data_Text_1 & Data_Text_2) from the 3 tables.
I've used
$html = file_get_contents($link);
$doc = new DOMDocument();
@$doc->loadHTML($html);
$xpath = new DOMXPath($doc);
$nodes = $xpath->query('//td[]');
$nodes2 = $xpath->query('//td[]');
But it cant show any data !
I'll offer bounty for this question on day after tomorrow
"Data_Text"from Table 2 -- it doesn't have a text node with such string value. Please, edit and correct.