The xml serializer in the FOSRestBundle doesn't serialize arrays with the key. Each array entry will result as <entry>
in the response, regardless of the key. The output in your example is correct. Keys are only in the json output relevant.
Serialized entities have the correct output, as the field will result in <field>value</field>
Example controller
/**
* @ApiDoc(
* description="Returns the own user details",
* statusCodes={
* 200="Returned when successful",
* 403="Returned when missing permissions",
* }
* )
*
* @Rest\Get("/users/me")
* @Rest\View(serializerGroups={"details"})
*/
public function getMeAction()
{
$user = $this->getUser();
return array('user' => $user);
}
and the response. You see, the key user
is outputted as <entry>
.
<?xml version="1.0" encoding="UTF-8"?>
<result>
<entry>
<id><![CDATA[517781e2e707a00217000000]]></id>
<username><![CDATA[admin]]></username>
<email><![CDATA[admin@example.com]]></email>
<company><![CDATA[acme]]></company>
</entry>
</result>