private function extractXmlAndAttachment($response)
    {
        $attachment = array('data' => null, 'mimeType' => null);

        preg_match('/\r\n/', $response, $matches, PREG_OFFSET_CAPTURE);
        $boundary = substr($response, 0, $matches[0][1]);

        $xmlStartPos = strpos($response, '<?xml ');
        $xmlEndPos = strpos($response, $boundary, $xmlStartPos) - 2;
        $xml = substr($response, $xmlStartPos, $xmlEndPos - $xmlStartPos);

        preg_match('/\r\n\r\n/', $response, $matches, PREG_OFFSET_CAPTURE, $xmlEndPos);
        $attachmentStartPos = $matches[0][1] + 4;
        $attachmentEndPos = strpos($response, $boundary, $attachmentStartPos) - 2;
        $attachment['data'] = substr($response, $attachmentStartPos, $attachmentEndPos - $attachmentStartPos);

        $mimeTypeStartPos = strpos($response, 'Content-Type: ', $xmlEndPos) + 14;
        preg_match('/\r\n/', $response, $matches, PREG_OFFSET_CAPTURE, $mimeTypeStartPos);
        $mimeTypeEndPos = $matches[0][1];
        $attachment['mimeType'] = substr($response, $mimeTypeStartPos, $mimeTypeEndPos - $mimeTypeStartPos);

        return array($xml, $attachment);
    }
private function extractXmlAndAttachment($response)
    {
        $attachment = array('data' => null, 'mimeType' => null);

        preg_match('/\r\n/', $response, $matches, PREG_OFFSET_CAPTURE);
        $boundary = substr($response, 0, $matches[0][1]);

        $xmlStartPos = strpos($response, '<?xml ');
        $xmlEndPos = strpos($response, $boundary, $xmlStartPos) - 2;
        $xml = substr($response, $xmlStartPos, $xmlEndPos - $xmlStartPos);

        preg_match('/\r\n\r\n/', $response, $matches, PREG_OFFSET_CAPTURE, $xmlEndPos);
        $attachmentStartPos = $matches[0][1] + 4;
        $attachmentEndPos = strpos($response, $boundary, $attachmentStartPos) - 2;
        $attachment['data'] = substr($response, $attachmentStartPos, $attachmentEndPos - $attachmentStartPos);

        $mimeTypeStartPos = strpos($response, 'Content-Type: ', $xmlEndPos) + 14;
        preg_match('/\r\n/', $response, $matches, PREG_OFFSET_CAPTURE, $mimeTypeStartPos);
        $mimeTypeEndPos = $matches[0][1];
        $attachment['mimeType'] = substr($response, $mimeTypeStartPos, $mimeTypeEndPos - $mimeTypeStartPos);

        return array($xml, $attachment);
    }
private function extractXmlAndAttachment ( $ response ) { $ attachment = array ( 'data' => null , 'mimeType' => null ) ; preg_match ( '/\r\n/' , $ response , $ matches , PREG_OFFSET_CAPTURE ) ; $ boundary = substr ( $ response , 0 , $ matches [ 0 ] [ 1 ] ) ; $ xmlStartPos = strpos ( $ response , '<?xml ' ) ; $ xmlEndPos = strpos ( $ response , $ boundary , $ xmlStartPos ) - 2 ; $ xml = substr ( $ response , $ xmlStartPos , $ xmlEndPos - $ xmlStartPos ) ; preg_match ( '/\r\n\r\n/' , $ response , $ matches , PREG_OFFSET_CAPTURE , $ xmlEndPos ) ; $ attachmentStartPos = $ matches [ 0 ] [ 1 ] + 4 ; $ attachmentEndPos = strpos ( $ response , $ boundary , $ attachmentStartPos ) - 2 ; $ attachment [ 'data' ] = substr ( $ response , $ attachmentStartPos , $ attachmentEndPos - $ attachmentStartPos ) ; $ mimeTypeStartPos = strpos ( $ response , 'Content-Type: ' , $ xmlEndPos ) + 14 ; preg_match ( '/\r\n/' , $ response , $ matches , PREG_OFFSET_CAPTURE , $ mimeTypeStartPos ) ; $ mimeTypeEndPos = $ matches [ 0 ] [ 1 ] ; $ attachment [ 'mimeType' ] = substr ( $ response , $ mimeTypeStartPos , $ mimeTypeEndPos - $ mimeTypeStartPos ) ; return array ( $ xml , $ attachment ) ; }
Extracts the XML and the attachment from the response if it contains an attachment.

@param string The XML response body.

@return string The XML part of response body.
Extracts the XML and the attachment from the response if it contains an attachment .