DOMCharacterData::remove
PHP function
Edit on GitHub ✎
(PHP 8)
Removes the character data node
Description
DOMCharacterData::remove(): void
Removes the character data node.
Examples
DOMCharacterData::remove example
Removes the character data.
php
<?php
$doc = new DOMDocument;
$doc->loadXML("<container><![CDATA[hello]]><world/></container>");
$cdata = $doc->documentElement->firstChild;
$cdata->remove();
echo $doc->saveXML();
?>The above example will output:
output
<?xml version="1.0"?>
<container><world/></container>See Also
DOMChildNode::removeDOMCharacterData::afterDOMCharacterData::beforeDOMCharacterData::replaceWithDOMNode::removeChild