My XML View files contain (for exporting records via XML):
<records><?php echo $this->Xml->serialize($records); ?></records>
After upgrading to 2.0 I realized there is no Xml helper anymore.
But the Xml class itself doesnt seem to provide an equally powerful method anymore, either.
It only contains sth like
$Xml = Xml::fromArray($records, array('format' => 'attribute'));
...
<records><?php echo $Xml->asXML(); ?></records>
But that – of course – fails because it can only transform “one record at a time”.
It also fails if I force it into a single parent key like
$records = array('records'=>$records);
first…
No clue how to get the XML export stuff working, again.
especially, as it seems, the expected input for the 2.0 XML class (http://book.cakephp.org/2.0/en/core-utility-libraries/xml.html#Xml) is quite different from what the model returns (and would probably have to be transformed somehow).
Old structure (and like the model respectably):
$records = array(
array('Project'=>array('field'=>'value', ...)),
array('Project'=>array('field'=>'value', ...)),
);
New structure
$records = array(
'projects' => array(
'project' => array(
array(
'id' => 1, 'title' => 'Project 1',
'industry' => array('id' => 1, 'name' => Industry 1')
),
array(
'id' => 2, 'title' => 'Project 2',
'industry' => array('id' => 2, 'name' => Industry 2')
)
)
)
);
Totally incompatible to what the model gives us, or so it seems.
the answer to it is pretty simply I found out shortly after asking the question via http://cakephp.lighthouseapp.com/projects/42648/tickets/2789-xml-view-defect
basically, you always need a single parent. so the old syntax could be seen as invalid. therefore upgrading and moving to the outlined new structure seems to be a requirement.