/** * Convert XML document into array. * * @param string $xmlRequestBody XML document * @return array Data converted from XML document to array. Root node is excluded from response. * @throws InvalidArgumentException In case of invalid argument type. * @throws Mage_Webapi_Exception If decoding error occurs. */ public function interpret($xmlRequestBody) { if (!is_string($xmlRequestBody)) { throw new InvalidArgumentException(sprintf('Invalid data type "%s". String is expected.', gettype($xmlRequestBody))); } /** Disable external entity loading to prevent possible vulnerability */ $previousLoaderState = libxml_disable_entity_loader(true); set_error_handler(array($this, 'handleErrors')); $this->_xmlParser->loadXML($xmlRequestBody); restore_error_handler(); libxml_disable_entity_loader($previousLoaderState); /** Process errors during XML parsing. */ if ($this->_errorMessage !== null) { if (!$this->_app->isDeveloperMode()) { $exceptionMessage = $this->_helper->__('Decoding error.'); } else { $exceptionMessage = 'Decoding Error: ' . $this->_errorMessage; } throw new Mage_Webapi_Exception($exceptionMessage, Mage_Webapi_Exception::HTTP_BAD_REQUEST); } $data = $this->_xmlParser->xmlToArray(); /** Data will always have exactly one element so it is safe to call reset here. */ return reset($data); }