Parse data from response

@return string
@throws OssException
761814
protected function parseDataFromResponse()
    {
        $content = $this->rawResponse->body;
        if (empty($content)) {
            throw new OssException("body is null");
        }
        $xml = simplexml_load_string($content);
        if (isset($xml->StorageCapacity)) {
            return intval($xml->StorageCapacity);
        } else {
            throw new OssException("xml format exception");
        }
    }
141222
private function parse($body)
    {
        $xml = simplexml_load_string($body);

        $data = $xml->xpath('//soap:Body');

        $response = array();

        foreach ($data as $node) {
            $this->parseElement($response, $node);
        }

        return $response;
    }
915427
public function parseResponse($response, $code = 4)
    {
        $domResponse = new DOMDocument();
        $domResponse->loadXML($response);

        if ($code === 200 || $code == 0) {
            return $response;
        } else {
            $errorCode = $domResponse->getElementsByTagName('SifraGreske')->item(0);
            $errorMessage = $domResponse->getElementsByTagName('PorukaGreske')->item(0);
            $faultCode = $domResponse->getElementsByTagName('faultcode')->item(0);
            $faultMessage = $domResponse->getElementsByTagName('faultstring')->item(0);

            if ($errorCode && $errorMessage) {
                throw new Exception(sprintf('[%s] %s', $errorCode->nodeValue, $errorMessage->nodeValue));
            } else {
                if ($faultCode && $faultMessage) {
                    throw new Exception(sprintf('[%s] %s', $faultCode->nodeValue, $faultMessage->nodeValue));
                } else {
                    throw new Exception(print_r($response, true), $code);
                }
            }
        }
    }
292946
protected function parseDataFromResponse()
    {
        $content = $this->rawResponse->body;
        $xml = simplexml_load_string($content);
        if (isset($xml->UploadId)) {
            return strval($xml->UploadId);
        }
        throw new OssException("cannot get UploadId");
    }
566425
private function getParsedData()
    {
        if (is_array($this->parsedData)) {
            return $this->parsedData;
        }

        $this->parsedData = [
            'routes' => []
        ];

        $content = $this->getYmlFileContent();
        try {
            $parsedData = $this->parser->parse($content);
            $this->addGeneralDefaults($parsedData);
            $this->addDataRoutes($parsedData);
        } catch (ParseException $caught) {
            throw new RoutesFileParserException(
                $caught->getMessage(),
                0,
                $caught
            );
        }
        return $this->parsedData;
    }
1201864
public function parse()
    {
        try {
            $xml       = simplexml_load_string($this->parsedMail->getMessageBody());
        } catch(\Exception $e) {
            $this->warningCount++;

            return $this->failed('XML expected, but got something else. Make sure google is set to send XML based reports!');
        }


        $timestamp = strtotime($xml->attributes()->date);

        foreach ($xml->list as $reports) {
            $this->feedName = (string)$reports->attributes()->type;

            // If feed is known and enabled, validate data and save report
            if ($this->isKnownFeed() && $this->isEnabledFeed()) {
                foreach ($reports->url_info as $url_info) {
                    $url = (string)$url_info->attributes()->url;
                    $ip = (string)$url_info->attributes()->ip;

                    $urlData = getUrlData($url);

                    if (filter_var($ip, FILTER_VALIDATE_IP) === false) {
                        // No IP supplied by Google
                        if (!empty($urlData['host']) &&
                            !filter_var($urlData['host'], FILTER_VALIDATE_IP) === false
                        ) {
                            // Hostname is an IP address
                            $ip = $urlData['host'];
                        } else {
                            // We have no IP address, try to get the IP address by resolving the domain
                            $ip = @gethostbyname($urlData['host']);

                            // If it fails, set to localhost
                            $ip = ($ip == $urlData['host']) ? '127.0.0.1' : $ip;
                        }
                    }

                    $report = [
                        'domain'    => getDomain($url),
                        'uri'       => getUri($url),
                        'category'  => config("{$this->configBase}.feeds.{$this->feedName}.category"),
                    ];

                    // Sanity check
                    if ($this->hasRequiredFields($report) === true) {
                        // incident has all requirements met, filter and add!
                        $report = $this->applyFilters($report);

                        $incident = new Incident();
                        $incident->source      = config("{$this->configBase}.parser.name");
                        $incident->source_id   = false;
                        $incident->ip          = $ip;
                        $incident->domain      = $report['domain'];
                        $incident->class       = config("{$this->configBase}.feeds.{$this->feedName}.class");
                        $incident->type        = config("{$this->configBase}.feeds.{$this->feedName}.type");
                        $incident->timestamp   = $timestamp;
                        $incident->information = json_encode(array_merge($urlData, $report));

                        $this->incidents[] = $incident;
                    }
                }
            }
        }

        return $this->success();
    }
1215738
public function parse()
	{
		$ip = !empty($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : 'unavailable';
		$this->record->formatted = str_replace("{ip-address}", $ip, $this->record->formatted);
		return $this->record;
	}
59993
protected function getResponseMessage()
    {

        // read the first 4 bytes which include the length of the response
        $lengthEncoded = $this->client->read(4);

        if (strlen($lengthEncoded) < 4) {
            return new Message('', Message::TYPE_RESPONSE_VALUE);
        }

        $lengthInBytes = unpack('V1size', $lengthEncoded)['size'];

        if ($lengthInBytes <= 0) {
            return new Message('', Message::TYPE_RESPONSE_VALUE);
        }

        $responseData = $this->client->read($lengthInBytes);

        // return an empty message if the server did not send any response
        if (null === $responseData) {
            return new Message('', Message::TYPE_RESPONSE_VALUE);
        }

        $responseMessage = new Message();
        $responseMessage->initializeFromRconData($responseData);

        if ($lengthInBytes >= 4000) {
            $this->handleFragmentedResponse($responseMessage);
        }

        return $responseMessage;
    }
905390
public function parse()
    {
        $result = new stdClass();
        $cache = $parser = $exception = $cacheKey = $path = null;
        try {
            $path = $this->find(false);
            // Cached response
            $cache = new PathCache(__FUNCTION__, $this->options);
            $cacheKey = $cache->getKey([$path]);
            $result = $cache->readFrom($cacheKey);
            if ($result !== false) {
                return $result;
            }
            // Real response
            $parser = $this->getParser();
            $result = $parser->parse($path);
        } catch (InvalidArgumentException $exception) {
            $this->mergeMessages($exception, __FUNCTION__);
        }
        $this->mergeMessages($parser, __FUNCTION__);
        $this->mergeMessages($cache, __FUNCTION__);

        // Re-throw parser exception
        if ($exception) {
            throw $exception;
        }

        if ($cache && $cacheKey) {
            $cache->writeTo($cacheKey, $result, ['path' => $path]);
        }

        return $result;
    }
265882
protected function parseDataFromResponse()
    {
        $content = $this->rawResponse->body;
        $xml = simplexml_load_string($content);

        $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : "";
        $bucket = isset($xml->Bucket) ? strval($xml->Bucket) : "";
        $keyMarker = isset($xml->KeyMarker) ? strval($xml->KeyMarker) : "";
        $keyMarker = OssUtil::decodeKey($keyMarker, $encodingType);
        $uploadIdMarker = isset($xml->UploadIdMarker) ? strval($xml->UploadIdMarker) : "";
        $nextKeyMarker = isset($xml->NextKeyMarker) ? strval($xml->NextKeyMarker) : "";
        $nextKeyMarker = OssUtil::decodeKey($nextKeyMarker, $encodingType);
        $nextUploadIdMarker = isset($xml->NextUploadIdMarker) ? strval($xml->NextUploadIdMarker) : "";
        $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : "";
        $delimiter = OssUtil::decodeKey($delimiter, $encodingType);
        $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : "";
        $prefix = OssUtil::decodeKey($prefix, $encodingType);
        $maxUploads = isset($xml->MaxUploads) ? intval($xml->MaxUploads) : 0;
        $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : "";
        $listUpload = array();

        if (isset($xml->Upload)) {
            foreach ($xml->Upload as $upload) {
                $key = isset($upload->Key) ? strval($upload->Key) : "";
                $key = OssUtil::decodeKey($key, $encodingType);
                $uploadId = isset($upload->UploadId) ? strval($upload->UploadId) : "";
                $initiated = isset($upload->Initiated) ? strval($upload->Initiated) : "";
                $listUpload[] = new UploadInfo($key, $uploadId, $initiated);
            }
        }
        return new ListMultipartUploadInfo($bucket, $keyMarker, $uploadIdMarker,
            $nextKeyMarker, $nextUploadIdMarker,
            $delimiter, $prefix, $maxUploads, $isTruncated, $listUpload);
    }
521107
public function getData()
    {
        if (null == $this->_response) {
            $response = $this->_responseString;

            try {
                if ($this->getJsonBigintConversion()) {
                    $response = JSON::parse($response, true, 512, JSON_BIGINT_AS_STRING);
                } else {
                    $response = JSON::parse($response);
                }
            } catch (JSONParseException $e) {
                // leave response as is if parse fails
            }

            if (empty($response)) {
                $response = [];
            }

            if (\is_string($response)) {
                $response = ['message' => $response];
            }

            $this->_response = $response;
            $this->_responseString = '';
        }

        return $this->_response;
    }
425659
protected function parseAlt() {
    if (is_object($this->file)) {
      if (isset($this->file->alt)) {
        return $this->file->alt;
      }
    }

    if (is_array($this->file)) {
      if (isset($this->file['alt'])) {
        return $this->file['alt'];
      }
    }

    return '';
  }
376883
public function parse()
    {
        $path = $this->_contents;

        if (!isset($this->_parsed_data[$path])) {
            $context = $this->getCommandContext();
            $context->data = $path;
            $this->getCommandChain()->run(LibBaseTemplateFilter::MODE_READ, $context);
            $this->_parsed_data[$path] = $context->data;
        }

        return $this->_parsed_data[$path];
    }
230706
private function parse($body)
    {
        $xmlObject = simplexml_load_string($body);
        foreach ($xmlObject as $key => $value) {
            $response[$key] = (string) $value;
        }

        return $response;
    }
771047
private function parseClass()
    {
        $klass = get_class($this);

        if ($klass === __CLASS__) {
            return ['', 'Aws\Exception\AwsException'];
        }

        $service = substr($klass, strrpos($klass, '\\') + 1, -6);

        return [
            strtolower($service),
            "Aws\\{$service}\\Exception\\{$service}Exception"
        ];
    }
93737
public function parseHeader()
    {
        //$header = explode("\r\n", rtrim($this->response['headerRaw'], "\r\n"));
        
        $rawHeaders = rtrim($this->response['headerRaw'], "\r\n");
        # Handle multiple responses e.g. with redirections (proxies too)
        $headerGroups = explode("\r\n\r\n", $rawHeaders);
        # We're only interested in the last one
        $header = explode("\r\n", end($headerGroups));

        $output = array();

        if ('HTTP' === substr($header[0], 0, 4)) {
            list($output['version'], $output['status']) = explode(' ', $header[0]);
            unset($header[0]);
        }

        foreach ($header as $entry) {
            $pos = strpos($entry, ':');
            $output[trim(substr($entry, 0, $pos))] = trim(substr($entry, $pos + 1));
        }

        $this->response['header'] = $output;
        return $this;
    }
514101
public function jsonArray()
    {

        if (!$this->isContentType('application/json')) {
            throw new Exception('Response is not JSON');
        }

        if (empty($this->_jsonAsArray)) {
            $this->_jsonAsArray = Utils::json_parse($this->text(), true);
        }

        return $this->_jsonAsArray;

    }