Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/lib/zend/Zend/Service/Amazon/Ec2/Response.php
Go to the documentation of this file.
00001 <?php
00026 require_once 'Zend/Http/Response.php';
00027 
00035 class Zend_Service_Amazon_Ec2_Response {
00039     protected $_xmlNamespace = 'http://ec2.amazonaws.com/doc/2009-04-04/';
00040 
00048     private $_httpResponse = null;
00049 
00055     private $_document = null;
00056 
00062     private $_xpath = null;
00063 
00069     private $_errorCode = 0;
00070 
00076     private $_errorMessage = '';
00077 
00083     public function __construct(Zend_Http_Response $httpResponse)
00084     {
00085         $this->_httpResponse = $httpResponse;
00086     }
00087 
00093     public function getXPath()
00094     {
00095         if ($this->_xpath === null) {
00096             $document = $this->getDocument();
00097             if ($document === false) {
00098                 $this->_xpath = false;
00099             } else {
00100                 $this->_xpath = new DOMXPath($document);
00101                 $this->_xpath->registerNamespace('ec2',
00102                     $this->getNamespace());
00103             }
00104         }
00105 
00106         return $this->_xpath;
00107     }
00108 
00114     public function getDocument()
00115     {
00116         try {
00117             $body = $this->_httpResponse->getBody();
00118         } catch (Zend_Http_Exception $e) {
00119             $body = false;
00120         }
00121 
00122         if ($this->_document === null) {
00123             if ($body !== false) {
00124                 // turn off libxml error handling
00125                 $errors = libxml_use_internal_errors();
00126 
00127                 $this->_document = new DOMDocument();
00128                 if (!$this->_document->loadXML($body)) {
00129                     $this->_document = false;
00130                 }
00131 
00132                 // reset libxml error handling
00133                 libxml_clear_errors();
00134                 libxml_use_internal_errors($errors);
00135             } else {
00136                 $this->_document = false;
00137             }
00138         }
00139 
00140         return $this->_document;
00141     }
00142 
00148     public function getNamespace()
00149     {
00150         return $this->_xmlNamespace;
00151     }
00152 
00158     public function setNamespace($namespace)
00159     {
00160         $this->_xmlNamespace = $namespace;
00161     }
00162 
00163 }
 All Data Structures Namespaces Files Functions Variables Enumerations