Yii2. Action (method) in controller:
public function actionGet()
{
Yii::$app->response->format = Response::FORMAT_XML;
return [
'items' => [
['id' => 'data'],
['id' => 'body'],
],
];
}
At output get XML:
<?xml version="1.0" encoding="UTF-8"?>
<response>
<items>
<item>
<id>data</id>
</item>
<item>
<id>body</id>
</item>
</items>
</response>
How can add attributes in XML tags? And remove response tag:
<?xml version="1.0" encoding="UTF-8"?>
<items>
<item update="true">
<id>data</id>
</item>
<item update="false" new="true">
<id>body</id>
</item>
</items>
Documentation not show this case.