Skip to content
Snippets Groups Projects
SimpleRSSElement.php 755 B
Newer Older
  • Learn to ignore specific revisions
  • /**
     * @copyright  2020 Podlibre
     * @license    https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
     * @link       https://castopod.org/
     */
    
    
    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;
        }
    }