private function buildXml(array $array, \SimpleXMLElement &$xmlElem):\SimpleXMLElement
    {
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                if (!is_numeric($key)) {
                    $subnode = $xmlElem->addChild("$key");
                    $this->buildXml($value, $subnode);
                } else {
                    $subnode = $xmlElem->addChild("item$key");
                    $this->buildXml($value, $subnode);
                }
            } else {
                $xmlElem->addChild("$key", htmlspecialchars("$value"));
            }
        }
        return ($xmlElem);
    }
private function buildXml(array $array, \SimpleXMLElement &$xmlElem):\SimpleXMLElement
    {
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                if (!is_numeric($key)) {
                    $subnode = $xmlElem->addChild("$key");
                    $this->buildXml($value, $subnode);
                } else {
                    $subnode = $xmlElem->addChild("item$key");
                    $this->buildXml($value, $subnode);
                }
            } else {
                $xmlElem->addChild("$key", htmlspecialchars("$value"));
            }
        }
        return ($xmlElem);
    }
private function buildXml ( array $ array , \ SimpleXMLElement & $ xmlElem ) : \ SimpleXMLElement { foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( ! is_numeric ( $ key ) ) { $ subnode = $ xmlElem -> addChild ( "$key" ) ; $ this -> buildXml ( $ value , $ subnode ) ; } else { $ subnode = $ xmlElem -> addChild ( "item$key" ) ; $ this -> buildXml ( $ value , $ subnode ) ; } } else { $ xmlElem -> addChild ( "$key" , htmlspecialchars ( "$value" ) ) ; } } return ( $ xmlElem ) ; }
Build xml element
@param array $array Array to convert
@param \SimpleXMLElement $xmlElem xml Element
@return \SimpleXMLElement xml
Build xml element