I'm using PHP Simple HTML Dom library to get HTML from a webpage. I need fetch HTML between first tag inside 'div.page-content' and first 'h4' tag. Example:
<div class="page-content">
First text
<p>Second text</p>
<div>Third text</div>
<p>More text</p>
<h4>Subtitle 1</h4>
<p>bla bla</p>
<p>bla bla</p>
<h4>Subtitle 2</h4>
<p>bla bla</p>
<p>bla bla</p>
</div>
I've tried to to this:
$start = $html->find('div.page-content', 0);
while ( $next = $start->next_sibling() ) {
if ( $next->tag == 'h4')
break;
else{
echo $next->plaintext;
echo '<br/>';
$start = $next;
}
}
But it doesnt fetch nothing.
I need to fetch all:
First text
<p>Second text</p>
<div>Third text</div>
<p>More text</p>