$dom = new DOMDocument(); $dom->loadHTML(''); $parent = $dom->getElementsByTagName('div')->item(0); $child = $parent->getElementsByTagName('p')->item(0); $removedChild = $parent->removeChild($child);Child Node
$dom = new DOMDocument(); $dom->loadHTML('In both examples above, we first load an HTML string into a DOMDocument object using the `loadHTML` method. Then, we use the `getElementsByTagName` method to find the parent node and child node we want to remove. Finally, we use the `removeChild` method to remove the child node from the parent node. This method is part of the PHP DOM extension, which is included in PHP's core library. Therefore, no additional package or library is required to use this method.'); $parent = $dom->getElementsByTagName('div')->item(0); $child = $parent->getElementsByTagName('p')->item(1); $removedChild = $parent->removeChild($child);Child Node 1
Child Node 2
Child Node 3