Esempio n. 1
0
 /**
  * Convert the raw XML into an object
  *
  * @param \SimpleXMLElement $xml
  * @return Result
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $result = new Result();
     if (isset($xml->nofrecords)) {
         $result->setNumResults((int) $xml->nofrecords);
     }
     if (isset($xml->event)) {
         foreach ($xml->event as $event) {
             $result->addEvent(Event::createFromXML($event));
         }
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * Search the database
  *
  * @param Filter $filter
  * @return Result
  */
 public function search(Filter $filter)
 {
     $parameters = $filter->buildForRequest();
     $response = $this->doCall('/searchv2/search', $parameters);
     $xml = simplexml_load_string($response);
     if ($xml !== false) {
         $xml = $xml->children('http://www.cultuurdatabank.com/XMLSchema/CdbXSD/3.2/FINAL');
         if (empty($xml)) {
             throw new Exception('Invalid response.');
         }
     } else {
         throw new Exception('Invalid response.');
     }
     return Result::createFromXML($xml);
 }