Jak zwrócić XML w aplikacji Zend Framework

Mam problemy z zwracaniem XML w mojej aplikacji ZF. Mój kod:

class ProjectsController extends Gid_Controller_Action
{
    public function xmlAction ()
    {
        $content = "<?xml version='1.0'><foo>bar</foo>";
        header('Content-Type: text/xml');
        echo $content;
    }
}

Próbowałem również:

class ProjectsController extends Gid_Controller_Action
{
    public function xmlAction ()
    {
        $content = "<?xml version='1.0'><foo>bar</foo>";
        $this->getResponse()->clearHeaders();
        $this->getResponse()->setheader('Content-Type', 'text/xml');
        $this->getResponse()->setBody($content);
        $this->getResponse()->sendResponse();
    }
}

Czy ktoś mógłby wskazać mi właściwy kierunek, jak to osiągnąć?

questionAnswers(2)

yourAnswerToTheQuestion