Получить только строки таблицы из первой таблицы - Простой HTML Dom (PHP)
<table border="3" rules="all" cellpadding="1" cellspacing="1">
<tbody>
<tr>
<td align="center">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial" color="#000000"> <b>Maandag</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial"> <b>Dinsdag</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial"> <b>Woensdag</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial"> <b>Donderdag</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial"> <b>Vrijdag</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial"> <b>1</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="18" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *verlof </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_4. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O114 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V6A </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V6C </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr></tr>
<tr>
<td rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial"> <b>2</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_3. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O114 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V4B </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V4C </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_7. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V4B </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V4A </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr></tr>
<tr>
<td rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial"> <b>3</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_1. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V6A </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V6C </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_1. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V6A </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V6C </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr></tr>
<tr>
<td rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial"> <b>4</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr></tr>
<tr>
<td rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial"> <b>5</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> stip </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> Os1 </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_5. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V5B </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V5C </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_5. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V5B </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V5C </font>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr></tr>
<tr>
<td rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial"> <b>6</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_3. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V4B </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V4C </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_3. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V4B </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V4C </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr></tr>
<tr>
<td rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial"> <b>7</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_4. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V6A </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V6C </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_7. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V4B </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V4A </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_4. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V6A </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V6C </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_7. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V4B </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V4A </font>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr></tr>
<tr>
<td rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial"> <b>8</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_5. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V5B </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V5C </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td width="33%" nowrap="1"><font size="2" face="Arial"> *in_1. </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font>
</td>
<td width="33%" nowrap="1"><font size="2" face="Arial"> V6A </font>
</td>
</tr>
<tr>
<td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V6C </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr></tr>
<tr>
<td rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td align="center" nowrap="1"><font size="2" face="Arial"> <b>9</b> </font>
</td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
<td colspan="12" rowspan="2" align="center" nowrap="1">
<table>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr></tr>
</tbody>
</table>
Какой запрос в simplehtmldom можно использовать для выбора только первых строк таблицы? Как это: Таблица->(все строки)
Когда я пытаюсь этот вопрос: echo($html->find('table tr',0));
И я изменить ноль на 2 (например), он не возвращает следующую строку таблицы основной таблицы , Но вместо этого он возвращает строку таблицы frist таблицы sub в первой строке таблицы.
Не то, чтобы я не мог изменить способ представления таблицы, это таблица, с которой мне нужно работать.
Что я получаю сейчас, когда я выполняю: echo($html->find('table tr',2));
-> "Maandag"
То, что я хотел бы получить: <tr><td rowspan="2" align="center" nowrap="1"><table><tbody><tr><td align="center" nowrap="1"><font size="2" face="Arial"> <b>2</b> </font> </td> </tr></tbody></table></td> <td colspan="12" rowspan="2" align="center" nowrap="1"><table><tbody><tr><td></td></tr></tbody></table></td> <td colspan="12" rowspan="2" align="center" nowrap="1"><table><tbody><tr><td width="33%" nowrap="1"><font size="2" face="Arial"> *in_3. </font> </td> <td width="33%" nowrap="1"><font size="2" face="Arial"> O114 </font> </td> <td width="33%" nowrap="1"><font size="2" face="Arial"> V4B </font> </td> </tr><tr><td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V4C </font> </td> </tr></tbody></table></td> <td colspan="12" rowspan="2" align="center" nowrap="1"><table><tbody><tr><td width="33%" nowrap="1"><font size="2" face="Arial"> *in_7. </font> </td> <td width="33%" nowrap="1"><font size="2" face="Arial"> O112 </font> </td> <td width="33%" nowrap="1"><font size="2" face="Arial"> V4B </font> </td> </tr><tr><td colspan="3" width="33%" nowrap="1"><font size="2" face="Arial"> V4A </font> </td> </tr></tbody></table></td> <td colspan="12" rowspan="2" align="center" nowrap="1"><table><tbody><tr><td></td></tr></tbody></table></td></tr>
(следующая TableRow первого (основного) таблицы)
как я загрузить в HTML таблице:
$html = file_get_html($timetableURL);
$timeTable = $html->find('table',0); //I need to do this because the page with the timetable has more html tables, I tested this and it always fetches the timetable as seen above.
Смежный вопрос: PHP Simple HTML DOM Parser how to get TR only from first table только я хочу, чтобы выбрать второй или третьей строки первой таблицы, например.
echo($timeTable->find('tr',2));
Можете ли вы показать больше об этом, как о том, как ваш документ DOM инициализирует документ и загружает в него желаемый результат. Тогда мне будет легче. –
Добавил его, я также добавил связанный с ним вопрос, в котором у кого-то такая же проблема. – sloeberGJ