src/includes/classes/Core/Utils/Array2Xml.php
protected function convert(\DOMDocument $DOMDocument, \DOMElement $ParentDOMElement, array $array)
    {
        foreach ($array as $_child_key => $_child_value) {
            if (is_string($_child_key)) { // Allows duplicate string keys.
                $_child_key = preg_replace('/^[0-9]+_/u', '', $_child_key);
            }
            if (is_array($_child_value)) { // Nested tag.
                $_ChildDOMElement = $DOMDocument->createElement($_child_key);
                $ParentDOMElement->appendChild($_ChildDOMElement);
                $this->convert($DOMDocument, $_ChildDOMElement, $_child_value);
                //
            } elseif (is_scalar($_child_value)) { // Must be scalar.
                // String keys become attributes; numeric keys text nodes.
                $_child_value = (string) $_child_value; // Force string.

                if (is_string($_child_key)) {
                    $_ChildDOMAttr = $DOMDocument->createAttribute($_child_key);
                    $ParentDOMElement->appendChild($_ChildDOMAttr);
                    $_ChildDOMAttr->value = $this->c::escAttr($_child_value);
                } else {
                    $_ChildDOMText = $DOMDocument->createTextNode($_child_value);
                    $ParentDOMElement->appendChild($_ChildDOMText);
                }
            } else { // Fail on unexpected values.
                throw $this->c::issue('Unexpected non-scalar child value.');
            }
        } // unset($_child_key, $_child_value, $_ChildDOMElement, $_ChildDOMAttr, $_ChildDOMText);
    }
protected function convert(\DOMDocument $DOMDocument, \DOMElement $ParentDOMElement, array $array)
    {
        foreach ($array as $_child_key => $_child_value) {
            if (is_string($_child_key)) { // Allows duplicate string keys.
                $_child_key = preg_replace('/^[0-9]+_/u', '', $_child_key);
            }
            if (is_array($_child_value)) { // Nested tag.
                $_ChildDOMElement = $DOMDocument->createElement($_child_key);
                $ParentDOMElement->appendChild($_ChildDOMElement);
                $this->convert($DOMDocument, $_ChildDOMElement, $_child_value);
                //
            } elseif (is_scalar($_child_value)) { // Must be scalar.
                // String keys become attributes; numeric keys text nodes.
                $_child_value = (string) $_child_value; // Force string.

                if (is_string($_child_key)) {
                    $_ChildDOMAttr = $DOMDocument->createAttribute($_child_key);
                    $ParentDOMElement->appendChild($_ChildDOMAttr);
                    $_ChildDOMAttr->value = $this->c::escAttr($_child_value);
                } else {
                    $_ChildDOMText = $DOMDocument->createTextNode($_child_value);
                    $ParentDOMElement->appendChild($_ChildDOMText);
                }
            } else { // Fail on unexpected values.
                throw $this->c::issue('Unexpected non-scalar child value.');
            }
        } // unset($_child_key, $_child_value, $_ChildDOMElement, $_ChildDOMAttr, $_ChildDOMText);
    }
Array to XML handler.

@since 160829.74007 XML conversion utils.

@param \DOMDocument $DOMDocument      Class instance.
@param \DOMElement  $ParentDOMElement Class instance.
@param array        $array            Input array to convert.