CakePHP $xml->serialize($array); not vorking from view
I am trying to make some data from database available using XML, I have configured routing,.. and if I go to /Vfilers.xml I get properly redirected to XML layout. However serialize seems not to be working in my view. This is my XML default template:
<!-- app/views/layouts/xml/default.ctp -->
<?php echo $this->Xml->header(); ?>
<?php echo $content_for_lay开发者_运维知识库out; ?>
This is my controller code:
<?php
class VfilersController extends AppController {
var $components = array('RequestHandler');
var $helpers = array('Xml');
function index() {
$vfilers = $this->Vfiler->find('all');
if($this->RequestHandler->isXml()) {
pr($vfilers);
$this->set(compact('vfilers'));
}
}
}
?>
My app/views/vfilers/xml/index.ctp looks like this:
<?php $xml->serialize($vfilers); ?>
And my output from Apache server looks like this:
I have checked variable $vfilers and data structure there is following
Array
(
[0] => Array (
[Vfiler] => Array (
[id] => 4e2961fc-4618-4397-818a-238a52d1364c
)
[Filer] => Array (
[id] => 4e291e4c-a2b4-441c-8667-2adf52d1364c
)
[SyslogEvent] => Array (
)
[1] => Array (
[Vfiler] => Array (
[id] => 4e2961fc-4618-4397-818a-238a52d1364c
)
[Filer] => Array (
[id] => 4e291e4c-a2b4-441c-8667-2adf52d1364c
)
[SyslogEvent] => Array (
)
Only there is more values, different IDs in a fileds,... Any idea what I can be missing?
You need to echo the result of $xml->serialize
精彩评论