php8.5
Home/ Manual/ dom / domcharacterdata/ DOMCharacterData::remove

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::remove
  • DOMCharacterData::after
  • DOMCharacterData::before
  • DOMCharacterData::replaceWith
  • DOMNode::removeChild

Source: reference/dom/domcharacterdata/remove.xml · from the official PHP manual (php/doc-en)