code: public function format($response)
      {
          $charset = $this->encoding === null ? $response->charset : $this->encoding;
          if (stripos($this->contentType, 'charset') === false) {
              $this->contentType .= '; charset=' . $charset;
          }
          $response->getHeaders()->set('Content-Type', $this->contentType);
          if ($response->data !== null) {
              $dom = new DOMDocument($this->version, $charset);
              if (!empty($this->rootTag)) {
                  $root = new DOMElement($this->rootTag);
                  $dom->appendChild($root);
                  $this->buildXml($root, $response->data);
              } else {
                  $this->buildXml($dom, $response->data);
              }
              $response->content = $dom->saveXML();
          }
      }
docs: Formats the specified response.
  @param Response $response the response to be formatted.