In PHP it is easy to pass back an json objects by using the json_encode(). However is there an XML equivalent of this?
json_encode()
You could use xmlrpc_encode.
xmlrpc_encode
xmlrpc_encode ($your_array);
Be careful because this function is EXPERIMENTAL.
Reference: http://php.net/manual/en/function.xmlrpc-encode.php