Skip to content

How do you delete nodes? #43

@kokarn

Description

@kokarn

Hello!

I'm trying to do some easy html manipulation and I can't seem to figure it out.

According to the docs for sunra/php-simple-html-dom-parser which I figure should work (correct me if i'm wrong) you should be able to do this.

// Remove a element, set it's outertext as an empty string 
$e->outertext = '';

But in my testcase, that doesn't seem to work.
This is the relevant part of my code

$dom = new Dom;
$dom->loadStr( $pageMarkup, [] );
$menu = $dom->find( '.inPageMenu' );
$menu->outertext = '';
$html = $dom->outerHtml;

After that, the item with the class is still present in $html.

Am I going at this backwards or am I missing something?
Thanks in advance!

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions