You are here

function xmlrpc_value_get_xml in Drupal 6

Same name and namespace in other branches
  1. 4 includes/xmlrpc.inc \xmlrpc_value_get_xml()
  2. 5 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 89
Drupal XML-RPC library. Based on the IXR - The Incutio XML-RPC Library - (c) Incutio Ltd 2002-2005 Version 1.7 (beta) - Simon Willison, 23rd May 2005 Site: http://scripts.incutio.com/xmlrpc/ Manual: http://scripts.incutio.com/xmlrpc/manual.php This…

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;
}