How to return XML in a Zend Framework application

后端 未结 2 1483
旧巷少年郎
旧巷少年郎 2020-12-31 08:35

I\'m having problems returning XML in my ZF application. My code:

class ProjectsController extends Gid_Controller_Action
{
    public function xmlAction ()
          


        
2条回答
  •  Happy的楠姐
    2020-12-31 09:24

    You're missing the ending question mark on the xml tag:

    
    

    It should be

    
    

    Additionally, you will probably need to disable your layout so it prints only the xml. Put this line in your xmlAction() method

    $this->_helper->layout->disableLayout();
    

    You may want to consider the contextSwitch action helper

    Also, you may want to use DomDocument instead of typing out xml directly

提交回复
热议问题