Several Methods for Zend Framework to output xml. See the Code:
1.
Class TestController extends Zend_Controller_Action {/*** The default action-show the home page */public function indexAction () {$ content = "<? Xml version = '1. 0'?> <Foo> bar </foo> "; header ('content-Type: text/xml'); echo $ Content; exit ;}} add an exit statement; in this way, you do not need to close the view.
2.
Class TestController extends Zend_Controller_Action {/*** The default action-show the home page */public function indexAction () {// XML-related routine $ xml = new DOMDocument ('1. 0 ', 'utf-8'); $ xml-> appendChild ($ xml-> createElement ('foo', 'bar ')); $ output = $ xml-> saveXML (); // Both layout and view renderer shocould be disabled attributes: getStaticHelper ('viewrenderer')-> setNoRender (true); Zend_Layout :: getMvcInstance ()-> disableLayout (); // Setting up headers and body $ this-> _ response-> setHeader ('content-type', 'text/xml; charset = UTF-8 ')-> setBody ($ output) ;}} the second method can call the DOMDocument object to create richer xml.
This article is from the "Bob" blog