-
-
Notifications
You must be signed in to change notification settings - Fork 469
Closed
Description
I am trying to replace a node in my DOM with another one. But I am getting the error
"PHP Fatal error: Method PHPHtmlParser\Dom::__toString() must not throw an exception, caught Error: Cannot use object of type PHPHtmlParser\Dom\HtmlNode as array".
Here is the code I am using
$dom = new Dom;
$dom->load('<div class="all"><p>Hey bro, <a href="google.com">click here</a><br /> :)</p></div>');
$id = $dom->find('p')[0]->id();
$newChild = new HtmlNode('h1');
$dom->find('p')[0]->getParent()->replaceChild($id, $newChild);
echo $dom;Metadata
Metadata
Assignees
Labels
No labels