private function convertElement(DOMDocument $document, $element, $value): void
    {
        $sequential = self::isArrayAllKeySequential($value);

        if (! \is_array($value)) {
            $element->nodeValue = \htmlspecialchars((string) $value);

            return;
        }

        foreach ($value as $key => $data) {
            if (! $sequential) {
                if (($key === '_attributes') || ($key === '@attributes')) {
                    foreach ($data as $attrKey => $attrVal) {
                        $element->setAttribute($attrKey, (string) $attrVal);
                    }
                } elseif ((($key === '_value') || ($key === '@value')) && \is_string($data)) {
                    $element->nodeValue = \htmlspecialchars($data);
                } elseif ((($key === '_cdata') || ($key === '@cdata')) && \is_string($data)) {
                    $element->appendChild($document->createCDATASection($data));
                } else {
                    if (! \is_string($key)) {
                        throw new DOMException('Invalid Character Error.');
                    }

                    $this->addNode($document, $element, $key, $data);
                }
            } elseif (\is_array($data)) {
                $this->addCollectionNode($document, $element, $data);
            } else {
                $this->addSequentialNode($element, $data);
            }
        }
    }
private function convertElement(DOMDocument $document, $element, $value): void
    {
        $sequential = self::isArrayAllKeySequential($value);

        if (! \is_array($value)) {
            $element->nodeValue = \htmlspecialchars((string) $value);

            return;
        }

        foreach ($value as $key => $data) {
            if (! $sequential) {
                if (($key === '_attributes') || ($key === '@attributes')) {
                    foreach ($data as $attrKey => $attrVal) {
                        $element->setAttribute($attrKey, (string) $attrVal);
                    }
                } elseif ((($key === '_value') || ($key === '@value')) && \is_string($data)) {
                    $element->nodeValue = \htmlspecialchars($data);
                } elseif ((($key === '_cdata') || ($key === '@cdata')) && \is_string($data)) {
                    $element->appendChild($document->createCDATASection($data));
                } else {
                    if (! \is_string($key)) {
                        throw new DOMException('Invalid Character Error.');
                    }

                    $this->addNode($document, $element, $key, $data);
                }
            } elseif (\is_array($data)) {
                $this->addCollectionNode($document, $element, $data);
            } else {
                $this->addSequentialNode($element, $data);
            }
        }
    }
private function convertElement ( DOMDocument $ document , $ element , $ value ) : void { $ sequential = self :: isArrayAllKeySequential ( $ value ) ; if ( ! \ is_array ( $ value ) ) { $ element -> nodeValue = \ htmlspecialchars ( ( string ) $ value ) ; return ; } foreach ( $ value as $ key => $ data ) { if ( ! $ sequential ) { if ( ( $ key === '_attributes' ) || ( $ key === '@attributes' ) ) { foreach ( $ data as $ attrKey => $ attrVal ) { $ element -> setAttribute ( $ attrKey , ( string ) $ attrVal ) ; } } elseif ( ( ( $ key === '_value' ) || ( $ key === '@value' ) ) && \ is_string ( $ data ) ) { $ element -> nodeValue = \ htmlspecialchars ( $ data ) ; } elseif ( ( ( $ key === '_cdata' ) || ( $ key === '@cdata' ) ) && \ is_string ( $ data ) ) { $ element -> appendChild ( $ document -> createCDATASection ( $ data ) ) ; } else { if ( ! \ is_string ( $ key ) ) { throw new DOMException ( 'Invalid Character Error.' ) ; } $ this -> addNode ( $ document , $ element , $ key , $ data ) ; } } elseif ( \ is_array ( $ data ) ) { $ this -> addCollectionNode ( $ document , $ element , $ data ) ; } else { $ this -> addSequentialNode ( $ element , $ data ) ; } } }
Parse individual element.

@param \DOMDocument         $document
@param \DOMElement|\DOMNode $element
@param array|string         $value

@throws \DOMException

@return void
Parse individual element .