SimpleHTMLDom 库
SimpleHTMLDom Library
我正在使用这个库:http://simplehtmldom.sourceforge.net/manual.htm
我想在每一行中提取以下页面:
<div class="amx-form-entry-container">
<table style="font-size: 16px; color:#000">
<tbody><tr>
<td>Submitted by:</td>
<td>
Rami
</td>
</tr>
<tr>
<td>
Assignee:
</td>
<td> </td>
</tr>
<tr>
<td>
Subcategory:
</td>
<td> H: Documentation</td>
</tr>
<tr>
<td>
Description:
</td>
<td>Hello</td>
</tr>
<tr>
<td>
Case reference:
</td>
<td>
BEY/0517/4444
</td>
</tr>
<tr>
<td>
Status:
</td>
<td> Closed</td>
</tr>
<tr>
<td>
Created on:
</td>
<td> 19 May 2017</td>
</tr>
</tbody></table>
</div>
例如:
提交人:拉米
受让人:..
描述:你好
我已经完成了这段代码:
$oDom = new simple_html_dom();
$dd=$oDom->load($result);
$test= $oDom->find("div[class='amx-module amx-mr-form-panel']",0);
echo $test;
但它会将输出打印为 table,如果我查看页面源代码,我会看到与上面相同的代码。
- 我想要实现的是在一行中打印每个元素。
这是我的代码
$oDom->load($result);
$tables = $oDom->find('table');
$theData = array();
foreach($tables[0]->find('tr') as $row){
$rowData = array();
foreach($row->find('td') as $cell) {
$rowData[] = $cell->innertext;
}
$theData[] = $rowData;
}
echo "<pre>"; print_r($theData); echo "</pre>";
### Result ###
Array
(
[0] => Array
(
[0] => Submitted by:
[1] => Rami
)
[1] => Array
(
[0] => Assignee:
[1] =>
)
[2] => Array
(
[0] => Subcategory:
[1] => H: Documentation
)
[3] => Array
(
[0] => Description:
[1] => Hello
)
[4] => Array
(
[0] => Case reference:
[1] => BEY/0517/4444
)
[5] => Array
(
[0] => Status:
[1] => Closed
)
[6] => Array
(
[0] => Created on:
[1] => 19 May 2017
)
)
我正在使用这个库:http://simplehtmldom.sourceforge.net/manual.htm
我想在每一行中提取以下页面:
<div class="amx-form-entry-container">
<table style="font-size: 16px; color:#000">
<tbody><tr>
<td>Submitted by:</td>
<td>
Rami
</td>
</tr>
<tr>
<td>
Assignee:
</td>
<td> </td>
</tr>
<tr>
<td>
Subcategory:
</td>
<td> H: Documentation</td>
</tr>
<tr>
<td>
Description:
</td>
<td>Hello</td>
</tr>
<tr>
<td>
Case reference:
</td>
<td>
BEY/0517/4444
</td>
</tr>
<tr>
<td>
Status:
</td>
<td> Closed</td>
</tr>
<tr>
<td>
Created on:
</td>
<td> 19 May 2017</td>
</tr>
</tbody></table>
</div>
例如:
提交人:拉米
受让人:..
描述:你好
我已经完成了这段代码:
$oDom = new simple_html_dom();
$dd=$oDom->load($result);
$test= $oDom->find("div[class='amx-module amx-mr-form-panel']",0);
echo $test;
但它会将输出打印为 table,如果我查看页面源代码,我会看到与上面相同的代码。 - 我想要实现的是在一行中打印每个元素。
这是我的代码
$oDom->load($result);
$tables = $oDom->find('table');
$theData = array();
foreach($tables[0]->find('tr') as $row){
$rowData = array();
foreach($row->find('td') as $cell) {
$rowData[] = $cell->innertext;
}
$theData[] = $rowData;
}
echo "<pre>"; print_r($theData); echo "</pre>";
### Result ###
Array
(
[0] => Array
(
[0] => Submitted by:
[1] => Rami
)
[1] => Array
(
[0] => Assignee:
[1] =>
)
[2] => Array
(
[0] => Subcategory:
[1] => H: Documentation
)
[3] => Array
(
[0] => Description:
[1] => Hello
)
[4] => Array
(
[0] => Case reference:
[1] => BEY/0517/4444
)
[5] => Array
(
[0] => Status:
[1] => Closed
)
[6] => Array
(
[0] => Created on:
[1] => 19 May 2017
)
)