Message handler

@param string $xml
490746
public function message_handler($xml) {
		if(isset($xml->attrs['type'])) {
			$payload['type'] = $xml->attrs['type'];
		} else {
			$payload['type'] = 'chat';
		}
		$payload['from'] = $xml->attrs['from'];
		$payload['body'] = $xml->sub('body')->data;
		$payload['xml'] = $xml;
		$this->log->log("Message: {$xml->sub('body')->data}", XMPPHP_Log::LEVEL_DEBUG);
		$this->event('message', $payload);
	}
1277545
protected function parseXML($xml){
        if (!$xml){
            return false;
        }
        
        $this->response = array();
        $this->response['ReportRequestId'] = (string)$xml->ReportRequestId;
        $this->response['ReportType'] = (string)$xml->ReportType;
        $this->response['StartDate'] = (string)$xml->StartDate;
        $this->response['EndDate'] = (string)$xml->EndDate;
        $this->response['Scheduled'] = (string)$xml->Scheduled;
        $this->response['SubmittedDate'] = (string)$xml->SubmittedDate;
        $this->response['ReportProcessingStatus'] = (string)$xml->ReportProcessingStatus;
        
    }
899729
private function sendRequest($xml)
    {
        $url = $this->url;

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $url);
        curl_setopt($curl, CURLOPT_HTTPHEADER, ["Content-Type:application/xml"]);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POST, 1);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

        $resp = curl_exec($curl);
        if (false === $resp) {
            throw new Exception(curl_error($curl) . ' ' . curl_errno($curl), curl_errno($curl));
        }

        curl_close($curl);

        return $resp;
    }
1272139
public function detectNamespacesFromXml( $xml )
	{
		$namespaces	= self::getNamespacesFromXml( $xml );
		$this->namespaces	= array_merge( $this->namespaces, $namespaces );
		return count( $namespaces );
	}
41424
protected function loadXML($xml)
	{
		$this->checkUnsupported($xml);

		// Activate small nodes allocation and relax LibXML's hardcoded limits if applicable. Limits
		// on tags can be set during configuration
		$flags = (LIBXML_VERSION >= 20700) ? LIBXML_COMPACT | LIBXML_PARSEHUGE : 0;

		$useErrors = libxml_use_internal_errors(true);
		$dom       = new DOMDocument;
		$success   = $dom->loadXML($xml, $flags);
		libxml_use_internal_errors($useErrors);

		if (!$success)
		{
			throw new InvalidArgumentException('Cannot load XML: ' . libxml_get_last_error()->message);
		}

		return $dom;
	}
23520
public function dontSeeXmlResponseIncludes($xml)
    {
        $this->assertStringNotContainsString(
            XmlUtils::toXml($xml)->C14N(),
            XmlUtils::toXml($this->connectionModule->_getResponseContent())->C14N(),
            "found in XML Response"
        );
    }
955387
private function parseSignature(DOMElement $xml) : void
    {
        /** @var \DOMAttr[] $signatureMethod */
        $signatureMethod = Utils::xpQuery($xml, './ds:Signature/ds:SignedInfo/ds:SignatureMethod/@Algorithm');

        /* Validate the signature element of the message. */
        $sig = Utils::validateElement($xml);
        if ($sig !== false) {
            $this->wasSignedAtConstruction = true;
            $this->setCertificates($sig['Certificates']);
            $this->setSignatureData($sig);
            $this->setSignatureMethod($signatureMethod[0]->value);
        }
    }
341862
protected function parseSOAP12Response($xml)
    {
        $doc = new \DOMDocument('1.0', 'UTF-8');

        if ($doc->loadXML($xml) === false) {
            throw new Exception('Failed load xml');
        }

        $response = new Response();

        // Get the standard CDATA elements
        foreach (array('uri', 'checkedby', 'doctype', 'charset') as $var) {
            $element = $doc->getElementsByTagName($var);
            if ($element->length) {
                $response->{'set' . ucfirst($var)}($element->item(0)->nodeValue);
            }
        }

        // Handle the bool element validity
        $element = $doc->getElementsByTagName('validity');
        if ($element->length && $element->item(0)->nodeValue === 'true') {
            $response->setValidity(true);
        } else {
            $response->setValidity(false);
        }

        if (!$response->isValidity()) {
            $errors = $doc->getElementsByTagName('error');
            foreach ($errors as $error) {
                $response->addError(new Error($error));
            }
        }
        $warnings = $doc->getElementsByTagName('warning');
        foreach ($warnings as $warning) {
            $response->addWarning(new Warning($warning));
        }

        return $response;
    }
187054
public function validate( $xml )
	{
		$parser	= xml_parser_create();
		$dummy	= create_function( '', '' );
		xml_set_element_handler( $parser, $dummy, $dummy );
		xml_set_character_data_handler( $parser, $dummy );
		if( !xml_parse( $parser, $xml ) )
		{
			$msg	= "%s at line %d";
			$error	= xml_error_string( xml_get_error_code( $parser ) );
			$line	= xml_get_current_line_number( $parser );
			$this->error['message']	= sprintf( $msg, $error, $line );
			$this->error['line']	= $line;
			$this->error['xml']		= $xml;
			xml_parser_free( $parser );
			return FALSE;
		}
		xml_parser_free( $parser );
		return TRUE;
	}
445103
protected function parseXML($xml){
        if (!$xml){
            return false;
        }
        
        $this->response = array();
        $this->response['FeedSubmissionId'] = (string)$xml->FeedSubmissionId;
        $this->response['FeedType'] = (string)$xml->FeedType;
        $this->response['SubmittedDate'] = (string)$xml->SubmittedDate;
        $this->response['FeedProcessingStatus'] = (string)$xml->FeedProcessingStatus;
        
        $this->log("Successfully submitted feed #".$this->response['FeedSubmissionId'].' ('.$this->response['FeedType'].')');
    }
1151396
protected function loadXml( $xml )
	{
		$xsv	= new XML_DOM_SyntaxValidator;
		if( !$xsv->validate( $xml ) )
			throw new Exception( "XML Document is not valid:".$xsv->getErrors() );
		$this->document	= $xsv->getDocument();
		$this->clearOptions();
		foreach( $this->attributes as $attribute )
			if( isset( $this->document->$attribute ) )
				$this->setOption( $attribute, $this->document->$attribute );
	}
1082663
private function parseTextInput (SimpleXMLElement $xml)
    {
        return (new ReflectionClass(Input\Text::class))->newInstanceArgs(
            array_merge(
                $this->getCommonMessageProperties($xml),
                [$xml->Content]
            )    
        );
    }
649682
public function validateXML($xml)
    {
        $xmlValidator = new XMLValidator();
        $result = $xmlValidator->validateSchemaVersion($xml);
        if ($result === false) {
            $this->setResponse("verbosemessage", $xmlValidator->getValidationMessage());
            return false;
        }
        return true;
    }
744343
private function parseLinkInput (SimpleXMLElement $xml)
    {
        return (new ReflectionClass(Input\Link::class))->newInstanceArgs(
            array_merge(
                $this->getCommonMessageProperties($xml),
                [
                    (string)$xml->Url,
                    (string)$xml->Title,
                    (string)$xml->Description,
                ]
            )
        );
    }
612196
public function onMessage($handler)
    {
        if (!is_callable($handler)) {
            throw new InvalidArgumentException('Message handler should be callable.');
        }
        $this->eventDispatcher->addListener(static::EVENT_MESSAGE, function (Event $event) use ($handler) {
            $handler($event->getArgument('message'));
        });
    }
79728
protected function parseXML($xml){
        if (!$xml){
            return false;
        }
        foreach($xml->children() as $key=>$x){
            $i = $this->index;
            if ($key == 'Count'){
                $this->count = (string)$x;
                $this->log("Successfully cancelled $this->count report requests.");
            }
            if ($key != 'FeedSubmissionInfo'){
                continue;
            }
            
            $this->feedList[$i]['FeedSubmissionId'] = (string)$x->FeedSubmissionId;
            $this->feedList[$i]['FeedType'] = (string)$x->FeedType;
            $this->feedList[$i]['SubmittedDate'] = (string)$x->SubmittedDate;
            $this->feedList[$i]['FeedProcessingStatus'] = (string)$x->FeedProcessingStatus;
            //this fields are not always returned
            if (isset($x->StartedProcessingDate)) {
                $this->feedList[$i]['StartedProcessingDate'] = (string)$x->StartedProcessingDate;
            }
            if (isset($x->CompletedProcessingDate)) {
                $this->feedList[$i]['CompletedProcessingDate'] = (string)$x->CompletedProcessingDate;
            }
            
            $this->index++;
        }
    }
667287
protected function pbCheck( array $xml ) {

		$pt = 0;
		$ch = 0;
		$fm = 0;
		$bm = 0;
		$meta = 0;

		foreach ( $xml['posts'] as $p ) {

			if ( 'part' === $p['post_type'] ) {
				$pt = 1;
			} elseif ( 'chapter' === $p['post_type'] ) {
				$ch = 1;
			} elseif ( 'front-matter' === $p['post_type'] ) {
				$fm = 1;
			} elseif ( 'back-matter' === $p['post_type'] ) {
				$bm = 1;
			} elseif ( 'metadata' === $p['post_type'] ) {
				$meta = 1;
			}

			if ( $pt + $ch + $fm + $bm + $meta >= 2 ) {
				$this->isPbWxr = true;
				break;
			}
		}

	}