Change your set array to be players instead of output.
On Jan 23, 2013 6:01 PM, "Mariano C." <mariano.calan...@gmail.com> wrote:

> I have the players table with three field id, first_name, last_name. The
> PlayersController have method index that show every player in the table:
>
> public function index() {
>         $output = $this->Player->find('all');
>         $this->set(array(
>             'output' => $output,
>             '_serialize' => array('output')
>         ));
>         $this->render('generic_response');
>     }
>
> and the generic_response is an XML view that look like this:
>
> <?php
> $xml = Xml::fromArray(array('response' => $output));
> echo $xml->asXML();
>
> The resulting XML is:
>
> <response>
>   <output>
>      <Player>
>        <id>2</id>
>        <first_name>Ciro</first_name>
>        <second_name>Spee</second_name>
>      </Player>
>    </output>
>    <output>
>      <Player>
>        <id>3</id>
>        <first_name>Ugo</first_name>
>        <second_name>Ridi</second_name>
>      </Player>
>    </output></response>
>
> but I want something like:
>
> <response>
>   <players>
>      <Player>
>        <id>2</id>
>        <first_name>Ciro</first_name>
>        <second_name>Spee</second_name>
>      </Player>
>      <Player>
>        <id>3</id>
>        <first_name>Ugo</first_name>
>        <second_name>Ridi</second_name>
>      </Player>
>    </players></response>
>
> How can I do this?
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>
> ---
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com.
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>
>
>

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to