Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...

When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Returning Custom XML Responses

If you wish to return custom XML, simply return a DOMDocument, DOMElement or SimpleXMLElement object.

Example 703. Return Custom XML

 * Say Hello
 * @param string $who
 * @param string $when
 * @return SimpleXMLElement
function sayHello($who$when)
$xml ='<?xml version="1.0" encoding="ISO-8859-1"?>
    <value>Hey $who! Hope you\'re having a good $when</value>

$xml simplexml_load_string($xml);

$server = new Zend_Rest_Server();


The response from the service will be returned without modification to the client.

Zend Framework