function xmlrpc_value_get_xml

xmlrpc_value_get_xml($xmlrpc_value)

Generates XML representing the given value.

Parameters

$xmlrpc_value: A value to be represented in XML.

Return value

XML representation of $xmlrpc_value.

File

includes/xmlrpc.inc, line 96
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>" . check_plain($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;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!xmlrpc.inc/function/xmlrpc_value_get_xml/7.x