Append a value to a SimpleXmlElement

@param SimpleXMLElement $parent parent node
@param string $key value key
@param mixed $value value
@return SimpleXMLElement
198815
protected final function appendValueTo(
       SimpleXMLElement $parent,
       $key,
       $value): SimpleXMLElement
   {
       $parent->addChild($key);
       if (is_object($value) || is_array($value)) {
           foreach ($value as $subKey => $subValue) {
               $this->appendValueTo($parent->{$key}, $subKey, $subValue);
           }
           if (!isset($subKey)) {
               $parent->{$key}[0] = "";
           }
       } else if (is_scalar($value) || !$value) {
           $parent->{$key}[0] = (string) $value;
       }
       return $parent->{$key};
   }
547917
public static Element appendCDATAElement(Element parent, String tagName,
            String value) {
        Element child = appendElement(parent, tagName);
        if (value == null) { // avoid "null" word in the XML payload
            value = "";
        }

        Node cdata = child.getOwnerDocument().createCDATASection(value);
        child.appendChild(cdata);
        return child;
    }
222986
public function appends($key, $value = null)
    {
        if (is_null($key)) {
            return $this;
        }

        if (is_array($key)) {
            return $this->appendArray($key);
        }

        return $this->addQuery($key, $value);
    }
557993
protected function createTextNode(ElementNode $parent, $string)
    {
        if (count($parent->getChildren())) {
            $children = $parent->getChildren();
            $lastElement = end($children);
            reset($children);

            if ($lastElement->isTextNode()) {
                $lastElement->setValue($lastElement->getValue() . $string);

                return $lastElement;
            }
        }

        $textNode = new $this->textNodeClassName($string);
        $textNode->setNodeId(++$this->nextNodeid);
        $parent->addChild($textNode);

        return $textNode;
    }
780596
protected function addXmlElement(\DOMNode $parentNode, string $nodeName, string $namespace): \DOMNode
    {
        $node = $parentNode->appendChild(
            ($parentNode->ownerDocument ?? $parentNode)->createElementNS($namespace, $nodeName)
        );

        return $node;
    }
792450
public function prepend($value, $key = null)
    {
        $this->items = ArrayHelper::prepend($this->items, $value, $key);

        return $this;
    }
423734
public function toXML(DOMElement $parent) : DOMElement
    {
        Assert::notEmpty($this->lang, "Cannot convert Keywords to XML without a language set.");

        $doc = $parent->ownerDocument;

        $e = $doc->createElementNS(Common::NS, 'mdui:Keywords');
        $e->setAttribute('xml:lang', $this->lang);
        $value = '';
        foreach ($this->Keywords as $keyword) {
            if (strpos($keyword, "+") !== false) {
                throw new \Exception('Keywords may not contain a "+" character.');
            }
            $value .= str_replace(' ', '+', $keyword).' ';
        }
        $value = rtrim($value);
        $e->appendChild($doc->createTextNode($value));
        $parent->appendChild($e);

        return $e;
    }
682416
public function append($key, $value) {
        try {
            $result = $this->getRedis()->append($key, $value);
            if ($result !== false) {
                return $result;
            }
            throw new ImpossibleValueException();
        } catch (RedisException $ex) {
            throw new ConnectException();
        }
    }
481878
public function bind($key, $value = null)
    {
        $this->_parent_query->bind($key, $value);

        return $this;
    }
1219877
public function offsetSet($key, $value)
    {
        $this->validateValue($value);
        return parent::offsetSet($key, $value);
    }
147282
public function AddParent($parent)
    {
        $parent = str_replace("::", "\\", $parent);
        
        $this->parents[$parent] = $parent;
        $this->has_parent = true;
        
        return $this;
    }
46499
public static function addTo( &$source, $key, $subKey, $value = null )
    {
        $_target = static::clean( static::get( $source, $key, array() ) );
        static::set( $_target, $subKey, $value );
        static::set( $source, $key, $_target );

        return $_target;
    }
286381
public function build(SimpleXMLElement $parent = null) : SimpleXMLElement
    {
        if ($parent === null) {
            $xml = new SimpleXMLElement('<' . get_called_class()::getTagName() . "/>", LIBXML_PARSEHUGE);
        } else {
            $xml = $parent->addChild(get_called_class()::getTagName());
        }
        $this->setAttributes($xml);
        $this->setChilds($xml);

        return $xml;
    }
159663
public function xml(SimpleXMLElement $parent)
    {
        $command = $parent->addChild('command');
        $command->addAttribute('name', $this->_name);
        $command->addAttribute('help', $this->_help);

        return $parent;
    }
1278030
public function toXML(DOMElement $parent) : DOMElement
    {
        Assert::notEmpty($this->OrganizationName);
        Assert::notEmpty($this->OrganizationDisplayName);
        Assert::notEmpty($this->OrganizationURL);

        $doc = $parent->ownerDocument;

        $e = $doc->createElementNS(Constants::NS_MD, 'md:Organization');
        $parent->appendChild($e);

        Extensions::addList($e, $this->Extensions);

        Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationName', true, $this->OrganizationName);
        Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationDisplayName', true, $this->OrganizationDisplayName);
        Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationURL', true, $this->OrganizationURL);

        return $e;
    }
1103532
protected function mutateAttribute($key, $value)
    {
        $this->findUploadFields();

        if ($this->isUploadField($key)) {
            return $this->getAttribute($key);
        }

        return parent::mutateAttribute($key, $value);
    }
1297032
public function add($key, $value, $level=Document::LEVEL_ROOT) {
		parent::addMeta($key, $value, $level);
	}