Je rencontre des problèmes lors du renvoi de XML dans mon application ZF. Mon code:Comment renvoyer XML dans une application Zend Framework
class ProjectsController extends Gid_Controller_Action
{
public function xmlAction()
{
$content = "<?xml version='1.0'><foo>bar</foo>";
header('Content-Type: text/xml');
echo $content;
}
}
J'ai aussi essayé ce qui suit:
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();
}
}
Quelqu'un pourrait-il me diriger dans la bonne direction comment atteindre cet objectif?
comment faire la même chose dans Zend Framework 3? –