Ok I see what happens. there´s an issue between cakePHP query result array construction and the form that the xml helper expect to see it for a proper creation of the xml file. For example you construct an array for get all your posts ($posts = $this->Post->find('all');
)
This is what you get:
$posts = array(
'post' => array(
array(
'id' => '1',
'tittle' => 'The title'
),
array(
'id' => '2',
'tittle' => 'A title once again'
)
)
);
this what an instruction like $xml = Xml::build($xmlPosts);
on cakePHP expect on, for example, in a index.ctp file under your xml folder, inside View/Posts:
$posts = array(
'posts' => array(
'post' => array(
array(
'id' => '1',
'tittle' => 'The title'
),
array(
'id' => '2',
'tittle' => 'A title once again'
)
)
)
);
$xml = Xml::build($post);
The problem yields in that with XML parser needs a root element in the array.
the documentation on cakePHP dosen´t tell you that. So be careful on follow the example about REST services if you are a beginner on the cookbook.
You can fix the issue doing so array rearrangement in the index.ctp xml constructor. Something like this:
<?php
$xmlPosts = array('posts' => array('post' => $posts));
$xml = Xml::build($xmlPosts);
echo $xml->saveXML();
?>
I know is not the optimal solution. But I'm open to more thoughtful answers.