Braintree\Xml\Generator::arrayToXml PHP Method

arrayToXml() public static method

arrays passed to this method should have a single root element with an array as its value
public static arrayToXml ( array $aData ) : string
$aData array the array of data
return string XML string
    public static function arrayToXml($aData)
    {
        $aData = Util::camelCaseToDelimiterArray($aData, '-');
        // set up the XMLWriter
        $writer = new XMLWriter();
        $writer->openMemory();
        $writer->setIndent(true);
        $writer->setIndentString(' ');
        $writer->startDocument('1.0', 'UTF-8');
        // get the root element name
        $aKeys = array_keys($aData);
        $rootElementName = $aKeys[0];
        // open the root element
        $writer->startElement($rootElementName);
        // create the body
        self::_createElementsFromArray($writer, $aData[$rootElementName], $rootElementName);
        // close the root element and document
        $writer->endElement();
        $writer->endDocument();
        // send the output as string
        return $writer->outputMemory();
    }