I'm trying to parse through a page using PHP's Simple HTML DOM script, but unable to make the removals persist.
Firstly I want to clean up a few unwanted items. I've gone ahead and removed those outertexts by = ''.
However, whenever I run the next find, they show up again.
By visiting this Stack Overflow question, I noticed that I should be saving back to the variable.
I tried $html->save();
, but it throws up an error:
Fatal error: Uncaught Error: Call to undefined method simple_html_dom_node::save() in /var/www/public/...
If I remove this save()
, then when I run the next foreach, the div#bar
that I removed still shows up.
Any help would be appreciated!
foreach($html->find('div#foo') as $bullets) {
$bullets->find('div#bar',0)->outertext = '';
$bullets->save(); //this statement gives a fatal error
foreach($bullets->find('span.a-list-item') as $bulletpoints) {
echo "<br>".$bulletpoints."<br>";
}