Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

DOMChildNode

DOMChildNode is an interface introduced in version 8.0 for DOM nodes that can have siblings. It is implemented by DOMElement, DOMText, DOMComment, DOMProcessingInstruction, and DOMDocumentType.

It provides before() and after() to insert nodes adjacent to the current node, replaceWith() to replace it, and remove() to detach it from its parent.

<?php

    $dom = new DOMDocument;
    $dom->loadHTML('<p>Hello <b>world</b></p>');
    $b = $dom->getElementsByTagName('b')->item(0);
    $b->remove();

?>

Documentation

See Also