foreach ($node->childNodes
as $child_node) { if ($child_node instanceof \DOMCdataSection
) { $data =
$child_node->data;
if (!
str_contains($child_node->data, 'CDATA'
)) { $embed_prefix = "\n{
$comment_start}<![CDATA[{
$comment_end}\n";
$embed_suffix = "\n{
$comment_start}]]>{
$comment_end}\n";
$data =
$embed_prefix .
$data .
$embed_suffix;
} $fragment =
$node->ownerDocument->
createDocumentFragment();
$fragment->
appendXML($data);
$node->
appendChild($fragment);
$node->
removeChild($child_node);
} } } /**
* Decodes all HTML entities including numerical ones to regular UTF-8 bytes.
*
* Double-escaped entities will only be decoded once ("&lt;" becomes
* "<", not "<"). Be careful when using this function, as it will revert
* previous sanitization efforts (<script> will become <script>).
*
* This method is not the opposite of Html::escape(). For example, this method
* will convert "é" to "é", whereas Html::escape() will not convert "é"
* to "é".
*
* @param string $text
* The text to decode entities in.
*
* @return string
* The input $text, with all HTML entities decoded once.
*
* @see html_entity_decode()
* @see \Drupal\Component\Utility\Html::escape()
*/