如何排除特定的div
儿童被打印出来?
示例:从下面的代码中,父div被称为<div class="event-panel">
,其子div
,<div class="details">
和<div class="games">
的子<div class="wrap">
。
所以我想要的是内部的所有div都不应该打印出来,比如这个<div class="empty-outcome"> </div>
以及所有其他将在包装器div中,我已经使用过这个方法但是我不应该这样做我不知道我哪里错了。
应删除父div <div class="event-panel">
,请参阅下面的代码。
HTML结构:
<div class="event-panel">
<div class="details">
<div class="event-date">22:00</div>
<div class="event-name">Serie A 2017 v Winner</div>
</div>
<div class="games">
<div class="wrap">
<div class="empty-outcome"> </div>
<div class="empty-outcome"> </div>
<div class="empty-outcome"> </div>
<div class="empty-outcome"> </div>
<div class="empty-outcome"> </div>
<div class="empty-outcome"> </div>
<div class="empty-outcome"> </div>
<div class="empty-outcome"> </div>
<div class="empty-outcome"> </div>
<div class="empty-outcome"> </div>
</div>
<div class="full-event-button" onclick="prestige('/event /3123361')">+1</div>
</div>
</div>
执行代码:
<?php
include ('advanced_html_dom.php');
$html = file_get_html('https://sport.premierbet.com/tz/sport/1/#');
//Counting number of empty-outcome
$emptv = count($gameone = $html->find('div[class="empty-outcome"]'));
echo "Number of empty attribute is " . $emptv . '<br>';
//Print any data that i want but exclude this <div class="empty-outcome"> </div>
foreach ($html->find('empty-outcome') as $item)
{
$item->outertext = '';
$ret = $item->find('div[class="event-name"]');
echo "Event Name " . $ret . "<br>";
}
$html->clear();
?>
答案 0 :(得分:0)
您使用了错误的CSS,应该是:
$html->find('.empty-outcome')->remove;
这里也是删除这些内容的捷径:
success = await _myHid.SendOutputReportViaInterruptTransfer(_deviceData, _hidHandle, outputReportBuffer);