You are here

function xmlrpc_value_get_xml in xmlrpc 8

Generates XML representing the given value.

Parameters

object $xmlrpc_value: A value to be represented in XML.

Return value

bool|string XML representation of $xmlrpc_value. FALSE is the data cannot be serialized.

2 calls to xmlrpc_value_get_xml()
xmlrpc_request in ./xmlrpc.inc
Constructs an object representing an XML-RPC request.
xmlrpc_server in ./xmlrpc.server.inc
Invokes XML-RPC methods on this server.

File

./xmlrpc.inc, line 102
Drupal XML-RPC library.

Code

function xmlrpc_value_get_xml($xmlrpc_value) {
  switch ($xmlrpc_value->type) {
    case 'boolean':
      return '<boolean>' . ($xmlrpc_value->data ? '1' : '0') . '</boolean>';
    case 'int':
      return '<int>' . $xmlrpc_value->data . '</int>';
    case 'double':
      return '<double>' . $xmlrpc_value->data . '</double>';
    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>';
    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;
    case 'struct':
      $return = '<struct>' . "\n";
      foreach ($xmlrpc_value->data as $name => $value) {
        $return .= "  <member><name>" . Html::escape($name) . "</name><value>";
        $return .= xmlrpc_value_get_xml($value) . "</value></member>\n";
      }
      $return .= '</struct>';
      return $return;
    case 'date':
      return xmlrpc_date_get_xml($xmlrpc_value->data);
    case 'base64':
      return xmlrpc_base64_get_xml($xmlrpc_value->data);
  }
  return FALSE;
}