why does simple_html_dom find('tr')[0] get table row 2 instead of table
row 1?
why does find('tr')[0]; get table row 2 instead of table row 1 ?
This is my html all tables have the same class and layout.
<table class="tablemenu">
<tbody>
<tr>
<td><b>hello</b></td>
<td><b>hi</b></td>
<tr>
<tr>
<td>hey</td>
<td>Alright</td>
<td>Good</td>
<td><a>Date</a></td>
<tr>
</tbody>
</table>
<table class="tablemenu">
<tbody>
<tr>
<td><b>hello</b></td>
<td><b>hi</b></td>
<tr>
<tr>
<td>hey</td>
<td>Alright</td>
<td>Good</td>
<td><a>Date</a></td>
<tr>
</tbody>
</table>
<table class="tablemenu">
<tbody>
<tr>
<td><b>hello</b></td>
<td><a>hi</a></td>
<tr>
<tr>
<td>hey</td>
<td>Alright</td>
<td>Good</td>
<td><a>LINK</a></td>
<tr>
</tbody>
</table>
This is my php
<?php
include("simpleHtmlDom/simple_html_dom.php");
$html = new simple_html_dom();
// Load a file
$html->load_file('http://mySite.net/');
foreach($html->find('table[class=tablemenu]') as $element){
$Link = $element->find('tr')[0]->find('td')[4]->find('a')[0];
echo($Link->text());
echo '<br />';
}
?>
although it works i now can't access table row 1. to grab the word hi.
No comments:
Post a Comment