'; foreach ($payload as $key => $val) { $xml .= is_numeric($val) ? '<'.$key.'>'.$val.'' : '<'.$key.'>'; } $xml .= ''; return $xml; } public function unpack(string $payload): ?array { if (empty($payload)) { return []; } if (PHP_VERSION_ID < 80000) { libxml_disable_entity_loader(); } $data = json_decode(json_encode( simplexml_load_string($payload, 'SimpleXMLElement', LIBXML_NOCDATA), JSON_UNESCAPED_UNICODE ), true); if (JSON_ERROR_NONE === json_last_error()) { return $data; } return null; } }