Parses an XML-RPC message.
If parsing fails, the faultCode and faultString will be added to the message object.
$xmlrpc_message: An object generated by xmlrpc_message().
TRUE if parsing succeeded; FALSE otherwise.
function xmlrpc_message_parse($xmlrpc_message) {
$xmlrpc_message->_parser = xml_parser_create();
// Set XML parser to take the case of tags into account.
xml_parser_set_option($xmlrpc_message->_parser, XML_OPTION_CASE_FOLDING, FALSE);
// Set XML parser callback functions
xml_set_element_handler($xmlrpc_message->_parser, 'xmlrpc_message_tag_open', 'xmlrpc_message_tag_close');
xml_set_character_data_handler($xmlrpc_message->_parser, 'xmlrpc_message_cdata');
xmlrpc_message_set($xmlrpc_message);
if (!xml_parse($xmlrpc_message->_parser, $xmlrpc_message->message)) {
return FALSE;
}
xml_parser_free($xmlrpc_message->_parser);
// Grab the error messages, if any.
$xmlrpc_message = xmlrpc_message_get();
if (!isset($xmlrpc_message->messagetype)) {
return FALSE;
}
elseif ($xmlrpc_message->messagetype == 'fault') {
$xmlrpc_message->fault_code = $xmlrpc_message->params[0]['faultCode'];
$xmlrpc_message->fault_string = $xmlrpc_message->params[0]['faultString'];
}
return TRUE;
}