castopod/app/Libraries/SimpleRSSElement.php

33 lines
755 B
PHP
Raw Normal View History

<?php
/**
* @copyright 2020 Podlibre
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
* @link https://castopod.org/
*/
namespace App\Libraries;
use SimpleXMLElement;
class SimpleRSSElement extends SimpleXMLElement
{
/**
* Adds a child with $value inside CDATA
* @param unknown $name
* @param unknown $value
*/
public function addChildWithCDATA($name, $value = null, $namespace = null)
{
$new_child = $this->addChild($name, null, $namespace);
if ($new_child !== null) {
$node = dom_import_simplexml($new_child);
$no = $node->ownerDocument;
$node->appendChild($no->createCDATASection($value));
}
return $new_child;
}
}