diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Service/Amazon/SimpleDb/Response.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Service/Amazon/SimpleDb/Response.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,190 @@ +_httpResponse = $httpResponse; + } + + /** + * Gets the XPath object for this response + * + * @return DOMXPath the XPath object for response. + */ + public function getXPath() + { + if ($this->_xpath === null) { + $document = $this->getDocument(); + if ($document === false) { + $this->_xpath = false; + } else { + $this->_xpath = new DOMXPath($document); + $this->_xpath->registerNamespace('sdb', + $this->getNamespace()); + } + } + + return $this->_xpath; + } + + /** + * Gets the SimpleXML document object for this response + * + * @return SimpleXMLElement + */ + public function getSimpleXMLDocument() + { + try { + $body = $this->_httpResponse->getBody(); + } catch (Zend_Http_Exception $e) { + $body = false; + } + + + return simplexml_load_string($body); + } + + /** + * Get HTTP response object + * + * @return Zend_Http_Response + */ + public function getHttpResponse() + { + return $this->_httpResponse; + } + + /** + * Gets the document object for this response + * + * @return DOMDocument the DOM Document for this response. + */ + public function getDocument() + { + try { + $body = $this->_httpResponse->getBody(); + } catch (Zend_Http_Exception $e) { + $body = false; + } + + if ($this->_document === null) { + if ($body !== false) { + // turn off libxml error handling + $errors = libxml_use_internal_errors(); + + $this->_document = new DOMDocument(); + if (!$this->_document->loadXML($body)) { + $this->_document = false; + } + + // reset libxml error handling + libxml_clear_errors(); + libxml_use_internal_errors($errors); + } else { + $this->_document = false; + } + } + + return $this->_document; + } + + /** + * Return the current set XML Namespace. + * + * @return string + */ + public function getNamespace() + { + return $this->_xmlNamespace; + } + + /** + * Set a new XML Namespace + * + * @param string $namespace + */ + public function setNamespace($namespace) + { + $this->_xmlNamespace = $namespace; + } +}