You are here

public function HttpClientXMLFormatter::unserialize in Http Client 7.2

Same name and namespace in other branches
  1. 6.2 includes/HttpClientXMLFormatter.inc \HttpClientXMLFormatter::unserialize()

Unserializes data in the implemented format.

Parameters

string $data: The data that should be unserialized.

Return value

mixed The unserialized data.

Overrides HttpClientFormatter::unserialize

File

includes/formatter/HttpClientXMLFormatter.inc, line 96

Class

HttpClientXMLFormatter
Class for handling xml-responses. Returns a SimpleXML object

Code

public function unserialize($data) {
  $xml = simplexml_load_string($data);
  if ($xml instanceof SimpleXMLElement) {

    // Only return data if we got well formed xml
    return $xml;
  }
  else {

    // Data was messed up
    throw new InvalidArgumentException('XML response was malformed.');
  }
}