Zend Framework provides a way for that output xml.

Please do check the ContextSwitch action helper documentation.

The only thing you might want to change is force XML context in controller's init() method.

<?php

class SitemapController extends Controller_Action
{
    public function init()
    {
        $contextSwitch = $this->_helper->getHelper('contextSwitch');
        $contextSwitch->addActionContext('index', 'xml')->initContext('xml');
    }

    public function indexAction()
    {
    }
}

And ,the view script changed to index.xml.phtml ,not the index.phtml

Also , it will auto use http header Content-type: application/xml



Date: 2012-01-16 08:04:46 and last modified: 2012-01-16 08:08:49

Relate tags:

Hot tags: