XmlView (class)
Class XmlView
A view class that is used for creating XML responses.
By setting the '_serialize' key in your controller, you can specify a view variable that should be serialized to XML and used as the response for the request. This allows you to omit views + layouts, if your just need to emit a single view variable as the XML response.
In your controller, you could do the following:
$this->set(['posts' => $posts, '_serialize' => true]);
When the view is rendered, the $posts
view variable will be serialized into XML.
Note The view variable you specify must be compatible with Xml::fromArray().
You can also define '_serialize'
as an array. This will create an additional top level element named <response