public function Response::xml

Parse the XML response body and return a SimpleXMLElement

Return value

\SimpleXMLElement

Throws

RuntimeException if the response body is not in XML format

File

drupal/core/vendor/guzzle/http/Guzzle/Http/Message/Response.php, line 933

Class

Response
Guzzle HTTP response object

Namespace

Guzzle\Http\Message

Code

public function xml() {
  try {

    // Allow XML to be retrieved even if there is no response body
    $xml = new \SimpleXMLElement((string) $this->body ?: '<root />');
  } catch (\Exception $e) {
    throw new RuntimeException('Unable to parse response body into XML: ' . $e
      ->getMessage());
  }
  return $xml;
}