You are here

public function FormatterHalXml::render in RESTful 7.2

Renders an array in the selected format.

Parameters

array $structured_data: The data prepared to be rendered as returned by \RestfulFormatterInterface::prepare().

Return value

string The body contents for the HTTP response.

Overrides FormatterHalJson::render

File

modules/restful_example/src/Plugin/formatter/FormatterHalXml.php, line 40
Contains \Drupal\restful\Plugin\formatter\FormatterHalJson.

Class

FormatterHalXml
Class FormatterHalXml @package Drupal\restful\Plugin\formatter

Namespace

Drupal\restful_example\Plugin\formatter

Code

public function render(array $structured_data) {
  return $this
    ->arrayToXML($structured_data, new \SimpleXMLElement('<api/>'))
    ->asXML();
}