DOMElement::remove
PHP function
Edit on GitHub ✎
(PHP 8)
Removes the element
Description
DOMElement::remove(): void
Removes the element.
Examples
DOMElement::remove example
Removes the element.
php
<?php
$doc = new DOMDocument;
$doc->loadXML("<container><hello/><world/></container>");
$hello = $doc->documentElement->firstChild;
$hello->remove();
echo $doc->saveXML();
?>The above example will output:
output
<?xml version="1.0"?>
<container><world/></container>See Also
DOMElement::afterDOMElement::beforeDOMElement::replaceWithDOMNode::removeChild