(PHP 8)
DOMElement::remove — Removes the element
public DOMElement::remove(): void
Removes the element.
This function has no parameters.
No value is returned.
Example #1 DOMElement::remove() example
Removes the element.
<?php
$doc = new DOMDocument;
$doc->loadXML("<container><hello/><world/></container>");
$hello = $doc->documentElement->firstChild;
$hello->remove();
echo $doc->saveXML();
?> The above example will output:
<?xml version="1.0"?> <container><world/></container>
© 1997–2025 The PHP Documentation Group
Licensed under the Creative Commons Attribution License v3.0 or later.
https://www.php.net/manual/en/domelement.remove.php