Question

Hi i'm having below html structure,

<div id="main">
 <div class="contents">
  <div class="title">....</div>
  <div class="image"><img src="imagepath" /></div>
 </div>
</div>

Using below code i'm collecting all it's contents.

$description = trim(@$html->find('div[id=main]', 0)->innertext);

Now i'm trying to remove images within <div id="main"></div>

so far i tried @$html->find('div[class=image]', 0)->innertext = '';

But no changes. Any solution to solve this?

Was it helpful?

Solution

You were close, you want to use outertext:

$div = $html->find('#main', 0);
foreach($div->find('.image') as $img) $img->outertext = '';
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top