Parse the XML response body and return a SimpleXMLElement
\SimpleXMLElement
RuntimeException if the response body is not in XML format
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;
}