You are here

function xmlrpc_value_get_xml in Drupal 4

Same name and namespace in other branches
  1. 5 includes/xmlrpc.inc \xmlrpc_value_get_xml()
  2. 6 includes/xmlrpc.inc \xmlrpc_value_get_xml()
  3. 7 includes/xmlrpc.inc \xmlrpc_value_get_xml()

Generate XML representing the given value.

Parameters

$xmlrpc_value:

Return value

XML representation of value.

2 calls to xmlrpc_value_get_xml()
xmlrpc_request in includes/xmlrpc.inc
Construct an object representing an XML-RPC request
xmlrpc_server in includes/xmlrpcs.inc
The main entry point for XML-RPC requests.

File

includes/xmlrpc.inc, line 88

Code

function xmlrpc_value_get_xml($xmlrpc_value) {
  switch ($xmlrpc_value->type) {
    case 'boolean':
      return '<boolean>' . ($xmlrpc_value->data ? '1' : '0') . '</boolean>';
      break;
    case 'int':
      return '<int>' . $xmlrpc_value->data . '</int>';
      break;
    case 'double':
      return '<double>' . $xmlrpc_value->data . '</double>';
      break;
    case 'string':

      // Note: we don't escape apostrophes because of the many blogging clients
      // that don't support numerical entities (and XML in general) properly.
      return '<string>' . htmlspecialchars($xmlrpc_value->data) . '</string>';
      break;
    case 'array':
      $return = '<array><data>' . "\n";
      foreach ($xmlrpc_value->data as $item) {
        $return .= '  <value>' . xmlrpc_value_get_xml($item) . "</value>\n";
      }
      $return .= '</data></array>';
      return $return;
      break;
    case 'struct':
      $return = '<struct>' . "\n";
      foreach ($xmlrpc_value->data as $name => $value) {
        $return .= "  <member><name>" . check_plain($name) . "</name><value>";
        $return .= xmlrpc_value_get_xml($value) . "</value></member>\n";
      }
      $return .= '</struct>';
      return $return;
      break;
    case 'date':
      return xmlrpc_date_get_xml($xmlrpc_value->data);
      break;
    case 'base64':
      return xmlrpc_base64_get_xml($xmlrpc_value->data);
      break;
  }
  return FALSE;
}