protected function parseResults(RestfulService_Response $results) { $data = new DataObjectSet(); // Parse out items in the request element so we can create pager and other items. $request = $results->xpath('/shrs/rq'); $request = $request[0]; $rqTitle = $request->xpath('t'); $rqDate = $request->xpath('dt'); $rqStart = $request->xpath('si'); $rqCount = $request->xpath('rpd'); $rqTotal = $request->xpath('tr'); $rqTotalViewable = $request->xpath('tv'); $rqTotalViewable = intval($rqTotalViewable[0]); $this->searchTitle = strval($rqTitle[0]); $records = $results->xpath('/shrs/rs/r'); $zebra = 0; foreach ($records as $rec) { // create an empty dataobject to hold the job data $job = array(); // get each data node from the xml $title = $rec->xpath('jt'); $company = $rec->xpath('cn'); $source = $rec->xpath('src'); $type = $rec->xpath('ty'); $location = $rec->xpath('loc'); $seen = $rec->xpath('ls'); $posted = $rec->xpath('dp'); $excerpt = $rec->xpath('e'); // create new fields for each piece of data in the dataobject $job['ID'] = new Text(NULL); $job['ID']->setValue(md5(strval($title[0]))); $job['Title'] = new Text(NULL); $job['Title']->setValue(strval($title[0])); $job['Company'] = new Text(NULL); $job['Company']->setValue(strval($company[0])); $job['Source'] = new Text(NULL); // Need to grab the url attribute from the source element. $srcAttribs = $source[0]->attributes(); $job['Source']->setValue(strval($srcAttribs['url'])); $job['Location'] = new Text(NULL); $job['Location']->setValue(strval($location[0])); $job['LastSeen'] = new SS_DateTime(); $job['LastSeen']->setValue(strval($seen[0])); $job['DatePosted'] = new SS_DateTime(); $job['DatePosted']->setValue(strval($posted[0])); $job['Excerpt'] = new HTMLText(); $job['Excerpt']->setValue('<p>' . strval($excerpt[0]) . '</p>'); $job['Zebra'] = !$zebra ? 'odd' : 'even'; $zebra = !$zebra ? 1 : 0; $data->push(new ArrayData($job)); unset($job, $title, $company, $source, $type, $location, $seen, $posted, $excerpt); } $data->setPageLimits($this->page, $this->window, $rqTotalViewable); $data->setPaginationGetVar($this->pageVar); return $data; }