private function createXml(SimpleXMLElement $obj, array $array, ?string $prevKey = 'data'): void
    {
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                if (is_numeric($key)) {
                    $node = $obj->addChild($prevKey);
                    $this->createXml($node, $value);
                } elseif ($key == '@attributes') {
                    foreach ($value as $k => $v) {
                        $obj->addAttribute($k, $v);
                    }
                } else {
                    if ($prevKey != '' && !is_numeric($key)) $node = $obj->addChild($prevKey); else $node = $obj;
                    $this->createXml($node, $value, $key);
                }
            } else {
                if (is_numeric($key)) {
                    $obj->addChild($prevKey, $value);
                } else {
                    $obj->addChild($key, $value);
                }
            }
        }
    }
private function createXml(SimpleXMLElement $obj, array $array, ?string $prevKey = 'data'): void
    {
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                if (is_numeric($key)) {
                    $node = $obj->addChild($prevKey);
                    $this->createXml($node, $value);
                } elseif ($key == '@attributes') {
                    foreach ($value as $k => $v) {
                        $obj->addAttribute($k, $v);
                    }
                } else {
                    if ($prevKey != '' && !is_numeric($key)) $node = $obj->addChild($prevKey); else $node = $obj;
                    $this->createXml($node, $value, $key);
                }
            } else {
                if (is_numeric($key)) {
                    $obj->addChild($prevKey, $value);
                } else {
                    $obj->addChild($key, $value);
                }
            }
        }
    }
private function createXml ( SimpleXMLElement $ obj , array $ array , ? string $ prevKey = 'data' ) : void { foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { if ( is_numeric ( $ key ) ) { $ node = $ obj -> addChild ( $ prevKey ) ; $ this -> createXml ( $ node , $ value ) ; } elseif ( $ key == '@attributes' ) { foreach ( $ value as $ k => $ v ) { $ obj -> addAttribute ( $ k , $ v ) ; } } else { if ( $ prevKey != '' && ! is_numeric ( $ key ) ) $ node = $ obj -> addChild ( $ prevKey ) ; else $ node = $ obj ; $ this -> createXml ( $ node , $ value , $ key ) ; } } else { if ( is_numeric ( $ key ) ) { $ obj -> addChild ( $ prevKey , $ value ) ; } else { $ obj -> addChild ( $ key , $ value ) ; } } } }
Private method to create XML output

@param SimpleXMLElement $obj
@param array $array
@param null|string $prevKey
Private method to create XML output