public function sendContent(SendResponseEvent $e)
    {
        $response = $e->getResponse();
        if (!$response instanceof ApiProblemResponse) {
            return $this;
        }
        $response->getApiProblem()->setDetailIncludesStackTrace($this->displayExceptions());

        /** @var Request $request */
        $request  = $this->getMvcEvent()->getRequest();

        /** @var Accept $accept */
        $accept = $request->getHeader('Accept');

        if ($accept instanceof Accept && $accept->hasMediaType('text/xml')) {
            $arrayResponse = $response->getApiProblem()->toArray();

            $xmlWriter = new XmlWriter();

            if (array_key_exists('trace', $arrayResponse)) {
                array_walk($arrayResponse['trace'], function (&$item) {
                    unset($item['args']);
                });
            }
            if (array_key_exists('exception_stack', $arrayResponse)) {
                array_walk($arrayResponse['exception_stack'], function (&$item) {
                    array_walk($item['trace'], function (&$trace) {
                        unset($trace['args']);
                    });
                });
            }
            $output = $xmlWriter->processConfig($arrayResponse);

            echo $output;
            $e->setContentSent();
            return $this;
        }

        return parent::sendHeaders($e);
    }