php8.5
Home/ Manual/ dom / characterdata/ Dom\CharacterData::remove

Dom\CharacterData::remove

PHP function Edit on GitHub ✎

(PHP 8 >= 8.4.0)

Description

Dom\CharacterData::remove(): void

Examples

Dom\CharacterData::remove example

Removes the character data.

php
<?php
$doc = Dom\XMLDocument::createFromString("<container><![CDATA[hello]]><world/></container>");
$cdata = $doc->documentElement->firstChild;

$cdata->remove();

echo $doc->saveXML();
?>

The above example will output:

output
<?xml version="1.0" encoding="UTF-8"?>
<container><world/></container>

See Also

  • Dom\ChildNode::remove
  • Dom\CharacterData::after
  • Dom\CharacterData::before
  • Dom\CharacterData::replaceWith
  • Dom\Node::removeChild

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