$response] ); } return $jsonPayload; } /** * @param string $xml * * @throws ParserException * * @return \SimpleXMLElement */ protected function parseXml($xml, $response) { $priorSetting = libxml_use_internal_errors(true); try { libxml_clear_errors(); $xmlPayload = new \SimpleXMLElement($xml); if ($error = libxml_get_last_error()) { throw new \RuntimeException($error->message); } } catch (\Exception $e) { throw new ParserException( "Error parsing XML: {$e->getMessage()}", 0, $e, ['response' => $response] ); } finally { libxml_use_internal_errors($priorSetting); } return $xmlPayload; } }