/** * Returns response as XML * * If reponse is not a valid XML it is being created from * a DOM document which is being created from a text response * (this is the case for not valid HTML documents). * * @return SimpleXMLElement */ public function getResponseXML() { try { $this->responseXml = parent::getResponseXML(); } catch (Exception $exception) { $doc = new DOMDocument(); $doc->loadHTML($this->getResponseText()); $this->responseXml = simplexml_import_dom($doc); } return $this->responseXml; }
/** * Returns response as XML * * If reponse is not a valid XML it is being created from * a DOM document which is being created from a text response * (this is the case for not valid HTML documents). * * @return SimpleXMLElement */ public function getResponseXML() { try { $this->responseXml = parent::getResponseXML(); } catch (Exception $exception) { $doc = new DOMDocument(); $resp_str = $this->getResponseText(); // suppress error output libxml_use_internal_errors(true); $doc->loadHTML($resp_str); $this->responseXml = simplexml_import_dom($doc); // send errors to logger $errors = libxml_get_errors(); foreach ($errors as $error) { sfLogger::getInstance()->warning('{zWebBrowser::getResponseXML} ' . $this->displayXMLError($error)); } libxml_clear_errors(); } return $this->responseXml; }