简单的HTML Dom:如何删除span元素?

时间:2015-03-31 11:00:03

标签: php html simple-html-dom

我想删除带有Simple HTML Dom的span元素

<tr style="background-color:#ccffcc;">
<td style="text-align:center;"> 1.</td>
<td style="text-align:left;">Tante</td>
<td style="text-align:center;"><span style="visibility:hidden;">0</span>70:13<span style="visibility:hidden;">0</span></td>
</tr>

如何删除范围?

// initialize empty array to store the data array from each row
$theData = array();

// loop over rows
foreach($html->find('tr') as $row) {

    // initialize array to store the cell data from each row
    $rowData = array();
    foreach($row->find('td') as $cell) {

        foreach($cell->find('span') as $e)
    {
        $e->outertext = '';
    }

        // push the cell's text to the array
        $rowData[] = $cell->plaintext;
    }

    // push the row's data array to the 'big' array
    $theData[] = $rowData;
}

“准则”工作正常,但不删除范围。

0 个答案:

没有答案