Checks for a token and changes the proper options
@param SimpleXMLElement $xml <p>response data</p>
@return boolean <b>FALSE</b> if no XML data
773155
protected function checkToken($xml){
        if ($xml && $xml->NextToken && (string)$xml->HasNext != 'false' && (string)$xml->MoreResultsAvailable != 'false'){
            $this->tokenFlag = true;
            $this->options['NextToken'] = (string)$xml->NextToken;
        } else {
            unset($this->options['NextToken']);
            $this->tokenFlag = false;
        }
    }
167112
public static function validateXsdFromString($xml)
    {
        $xmlDocument = new \DOMDocument();
        $xmlDocument->loadXML($xml);

        return $xmlDocument->schemaValidate(__DIR__ . '/Resources/junit-4.xsd');
    }
83742
protected function parseXML($xml){
        if (!$xml) {
            return false;
        }

        if ($xml->InventoryRecommendationsLastUpdated) {
            $this->updated['Inventory'] = (string)$xml->InventoryRecommendationsLastUpdated;
        }
        if ($xml->SelectionRecommendationsLastUpdated) {
            $this->updated['Selection'] = (string)$xml->SelectionRecommendationsLastUpdated;
        }
        if ($xml->PricingRecommendationsLastUpdated) {
            $this->updated['Pricing'] = (string)$xml->PricingRecommendationsLastUpdated;
        }
        if ($xml->FulfillmentRecommendationsLastUpdated) {
            $this->updated['Fulfillment'] = (string)$xml->FulfillmentRecommendationsLastUpdated;
        }
        if ($xml->GlobalSellingRecommendationsLastUpdated) {
            $this->updated['GlobalSelling'] = (string)$xml->GlobalSellingRecommendationsLastUpdated;
        }
        if ($xml->AdvertisingRecommendationsLastUpdated) {
            $this->updated['Advertising'] = (string)$xml->AdvertisingRecommendationsLastUpdated;
        }

        if (isset($xml->InventoryRecommendations)) {
            foreach ($xml->InventoryRecommendations->children() as $x) {
                $this->list['Inventory'][] = $this->parseRecommendation($x);
            }
        }
        if (isset($xml->SelectionRecommendations)) {
            foreach ($xml->SelectionRecommendations->children() as $x) {
                $this->list['Selection'][] = $this->parseRecommendation($x);
            }
        }
        if (isset($xml->PricingRecommendations)) {
            foreach ($xml->PricingRecommendations->children() as $x) {
                $this->list['Pricing'][] = $this->parseRecommendation($x);
            }
        }
        if (isset($xml->FulfillmentRecommendations)) {
            foreach ($xml->FulfillmentRecommendations->children() as $x) {
                $this->list['Fulfillment'][] = $this->parseRecommendation($x);
            }
        }
        if (isset($xml->ListingQualityRecommendations)) {
            foreach ($xml->ListingQualityRecommendations->children() as $x) {
                $this->list['ListingQuality'][] = $this->parseRecommendation($x);
            }
        }
        if (isset($xml->GlobalSellingRecommendations)) {
            foreach ($xml->GlobalSellingRecommendations->children() as $x) {
                $this->list['GlobalSelling'][] = $this->parseRecommendation($x);
            }
        }
        if (isset($xml->AdvertisingRecommendations)) {
            foreach ($xml->AdvertisingRecommendations->children() as $x) {
                $this->list['Advertising'][] = $this->parseRecommendation($x);
            }
        }
    }
940079
protected function checkUnsupported($xml)
	{
		if (strpos($xml, '<!') !== false)
		{
			throw new InvalidArgumentException('DTDs, CDATA nodes and comments are not allowed');
		}
		if (strpos($xml, '<?') !== false)
		{
			throw new InvalidArgumentException('Processing instructions are not allowed');
		}
	}
1075581
public function identify( $xml )
	{
		$parser	= new XML_DOM_Parser();
		$tree	= $parser->parse( $xml );
		return $this->identifyFromTree( $tree );
	}
856378
public function isXml($xmlString)
    {
        $previousValue = libxml_use_internal_errors(true);

        $simpleXml = simplexml_load_string($xmlString);

        libxml_use_internal_errors($previousValue);

        return false !== $simpleXml;
    }
511604
protected function parseXML($xml){
        $this->list = array();
        if (!$xml){
            return false;
        }

        foreach ($xml->SubscriptionList->children() as $x) {
            $temp = array();
            $temp['NotificationType'] = (string)$x->NotificationType;
            $temp['IsEnabled'] = (string)$x->IsEnabled;
            $temp['Destination']['DeliveryChannel'] = (string)$x->Destination->DeliveryChannel;
            foreach ($x->Destination->AttributeList->children() as $z) {
                $temp['Destination']['AttributeList'][(string)$z->Key] = (string)$z->Value;
            }
            $this->list[] = $temp;
        }
    }
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;
        
    }
839561
protected function parseXML($xml){
        if (!$xml){
            return false;
        }
        $d = array();
        $d['AmazonOrderId'] = (string)$xml->AmazonOrderId;
        if (isset($xml->SellerOrderId)){
            $d['SellerOrderId'] = (string)$xml->SellerOrderId;
        }
        $d['PurchaseDate'] = (string)$xml->PurchaseDate;
        $d['LastUpdateDate'] = (string)$xml->LastUpdateDate;
        $d['OrderStatus'] = (string)$xml->OrderStatus;
        if (isset($xml->FulfillmentChannel)){
            $d['FulfillmentChannel'] = (string)$xml->FulfillmentChannel;
        }
        if (isset($xml->SalesChannel)){
            $d['SalesChannel'] = (string)$xml->SalesChannel;
        }
        if (isset($xml->OrderChannel)){
            $d['OrderChannel'] = (string)$xml->OrderChannel;
        }
        if (isset($xml->ShipServiceLevel)){
            $d['ShipServiceLevel'] = (string)$xml->ShipServiceLevel;
        }
        if (isset($xml->ShippingAddress)){
            $d['ShippingAddress'] = array();
            $d['ShippingAddress']['Name'] = (string)$xml->ShippingAddress->Name;
            $d['ShippingAddress']['AddressLine1'] = (string)$xml->ShippingAddress->AddressLine1;
            $d['ShippingAddress']['AddressLine2'] = (string)$xml->ShippingAddress->AddressLine2;
            $d['ShippingAddress']['AddressLine3'] = (string)$xml->ShippingAddress->AddressLine3;
            $d['ShippingAddress']['City'] = (string)$xml->ShippingAddress->City;
            $d['ShippingAddress']['County'] = (string)$xml->ShippingAddress->County;
            $d['ShippingAddress']['District'] = (string)$xml->ShippingAddress->District;
            $d['ShippingAddress']['StateOrRegion'] = (string)$xml->ShippingAddress->StateOrRegion;
            $d['ShippingAddress']['PostalCode'] = (string)$xml->ShippingAddress->PostalCode;
            $d['ShippingAddress']['CountryCode'] = (string)$xml->ShippingAddress->CountryCode;
            $d['ShippingAddress']['Phone'] = (string)$xml->ShippingAddress->Phone;
        }
        if (isset($xml->OrderTotal)){
            $d['OrderTotal'] = array();
            $d['OrderTotal']['Amount'] = (string)$xml->OrderTotal->Amount;
            $d['OrderTotal']['CurrencyCode'] = (string)$xml->OrderTotal->CurrencyCode;
        }
        if (isset($xml->NumberOfItemsShipped)){
            $d['NumberOfItemsShipped'] = (string)$xml->NumberOfItemsShipped;
        }
        if (isset($xml->NumberOfItemsUnshipped)){
            $d['NumberOfItemsUnshipped'] = (string)$xml->NumberOfItemsUnshipped;
        }
        if (isset($xml->PaymentExecutionDetail)){
            $d['PaymentExecutionDetail'] = array();
            
            $i = 0;
            foreach($xml->PaymentExecutionDetail->children() as $x){
                $d['PaymentExecutionDetail'][$i]['Amount'] = (string)$x->Payment->Amount;
                $d['PaymentExecutionDetail'][$i]['CurrencyCode'] = (string)$x->Payment->CurrencyCode;
                $d['PaymentExecutionDetail'][$i]['SubPaymentMethod'] = (string)$x->SubPaymentMethod;
                $i++;
            }
        }
        if (isset($xml->PaymentMethod)){
            $d['PaymentMethod'] = (string)$xml->PaymentMethod;
        }
        if (isset($xml->PaymentMethodDetails)){
            foreach ($xml->PaymentMethodDetails as $x) {
                $d['PaymentMethodDetails'][] = (string)$x->PaymentMethodDetail;
            }
        }
        if (isset($xml->IsReplacementOrder)){
            $d['IsReplacementOrder'] = (string)$xml->IsReplacementOrder;
            $d['ReplacedOrderId'] = (string)$xml->ReplacedOrderId;
        }
        $d['MarketplaceId'] = (string)$xml->MarketplaceId;
        if (isset($xml->BuyerName)){
            $d['BuyerName'] = (string)$xml->BuyerName;
        }
        if (isset($xml->BuyerEmail)){
            $d['BuyerEmail'] = (string)$xml->BuyerEmail;
        }
        if (isset($xml->BuyerCounty)){
            $d['BuyerCounty'] = (string)$xml->BuyerCounty;
        }
        if (isset($xml->BuyerTaxInfo)){
            $d['BuyerTaxInfo'] = array();
            if (isset($xml->BuyerTaxInfo->CompanyLegalName)){
                $d['BuyerTaxInfo']['CompanyLegalName'] = (string)$xml->BuyerTaxInfo->CompanyLegalName;
            }
            if (isset($xml->BuyerTaxInfo->TaxingRegion)){
                $d['BuyerTaxInfo']['TaxingRegion'] = (string)$xml->BuyerTaxInfo->TaxingRegion;
            }
            if (isset($xml->BuyerTaxInfo->TaxClassifications)){
                foreach($xml->BuyerTaxInfo->TaxClassifications->children() as $x){
                    $temp = array();
                    $temp['Name'] = (string)$x->Name;
                    $temp['Value'] = (string)$x->Value;
                    $d['BuyerTaxInfo']['TaxClassifications'][] = $temp;
                }
            }
        }
        if (isset($xml->ShipmentServiceLevelCategory)){
            $d['ShipmentServiceLevelCategory'] = (string)$xml->ShipmentServiceLevelCategory;
        }
        if (isset($xml->CbaDisplayableShippingLabel)){
            $d['CbaDisplayableShippingLabel'] = (string)$xml->CbaDisplayableShippingLabel;
        }
        if (isset($xml->ShippedByAmazonTFM)){
            $d['ShippedByAmazonTFM'] = (string)$xml->ShippedByAmazonTFM;
        }
        if (isset($xml->TFMShipmentStatus)){
            $d['TFMShipmentStatus'] = (string)$xml->TFMShipmentStatus;
        }
        if (isset($xml->OrderType)){
            $d['OrderType'] = (string)$xml->OrderType;
        }
        if (isset($xml->EarliestShipDate)){
            $d['EarliestShipDate'] = (string)$xml->EarliestShipDate;
        }
        if (isset($xml->LatestShipDate)){
            $d['LatestShipDate'] = (string)$xml->LatestShipDate;
        }
        if (isset($xml->EarliestDeliveryDate)){
            $d['EarliestDeliveryDate'] = (string)$xml->EarliestDeliveryDate;
        }
        if (isset($xml->LatestDeliveryDate)){
            $d['LatestDeliveryDate'] = (string)$xml->LatestDeliveryDate;
        }
        if (isset($xml->IsBusinessOrder)){
            $d['IsBusinessOrder'] = (string)$xml->IsBusinessOrder;
        }
        if (isset($xml->PurchaseOrderNumber)){
            $d['PurchaseOrderNumber'] = (string)$xml->PurchaseOrderNumber;
        }
        if (isset($xml->IsPrime)){
            $d['IsPrime'] = (string)$xml->IsPrime;
        }
        if (isset($xml->IsPremiumOrder)){
            $d['IsPremiumOrder'] = (string)$xml->IsPremiumOrder;
        }
        
        $this->data = $d;
    }
486966
public function dontSeeXmlResponseEquals($xml)
    {
        \PHPUnit\Framework\Assert::assertXmlStringNotEqualsXmlString(
            $this->connectionModule->_getResponseContent(),
            $xml
        );
    }
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;
	}
1141594
protected function parseXML($xml){
        if (!$xml){
            return false;
        }
        
        foreach($xml->children() as $item){
            $n = $this->index;
            
            $this->itemList[$n]['ASIN'] = (string)$item->ASIN;
            $this->itemList[$n]['SellerSKU'] = (string)$item->SellerSKU;
            $this->itemList[$n]['OrderItemId'] = (string)$item->OrderItemId;
            $this->itemList[$n]['Title'] = (string)$item->Title;
            $this->itemList[$n]['QuantityOrdered'] = (string)$item->QuantityOrdered;
            if (isset($item->QuantityShipped)){
                $this->itemList[$n]['QuantityShipped'] = (string)$item->QuantityShipped;
            }
            if (isset($item->BuyerCustomizedInfo->CustomizedURL)){
                $this->itemList[$n]['BuyerCustomizedInfo'] = (string)$item->BuyerCustomizedInfo->CustomizedURL;
            }
            if (isset($item->PointsGranted)){
                $this->itemList[$n]['PointsGranted']['PointsNumber'] = (string)$item->PointsGranted->PointsNumber;
                $this->itemList[$n]['PointsGranted']['Amount'] = (string)$item->PointsGranted->PointsMonetaryValue->Amount;
                $this->itemList[$n]['PointsGranted']['CurrencyCode'] = (string)$item->PointsGranted->PointsMonetaryValue->CurrencyCode;
            }
            if (isset($item->PriceDesignation)){
                $this->itemList[$n]['PriceDesignation'] = (string)$item->PriceDesignation;
            }
            if (isset($item->GiftMessageText)){
                $this->itemList[$n]['GiftMessageText'] = (string)$item->GiftMessageText;
            }
            if (isset($item->GiftWrapLevel)){
                $this->itemList[$n]['GiftWrapLevel'] = (string)$item->GiftWrapLevel;
            }
            if (isset($item->ItemPrice)){
                $this->itemList[$n]['ItemPrice']['Amount'] = (string)$item->ItemPrice->Amount;
                $this->itemList[$n]['ItemPrice']['CurrencyCode'] = (string)$item->ItemPrice->CurrencyCode;
            }
            if (isset($item->ShippingPrice)){
                $this->itemList[$n]['ShippingPrice']['Amount'] = (string)$item->ShippingPrice->Amount;
                $this->itemList[$n]['ShippingPrice']['CurrencyCode'] = (string)$item->ShippingPrice->CurrencyCode;
            }
            if (isset($item->GiftWrapPrice)){
                $this->itemList[$n]['GiftWrapPrice']['Amount'] = (string)$item->GiftWrapPrice->Amount;
                $this->itemList[$n]['GiftWrapPrice']['CurrencyCode'] = (string)$item->GiftWrapPrice->CurrencyCode;
            }
            if (isset($item->ItemTax)){
                $this->itemList[$n]['ItemTax']['Amount'] = (string)$item->ItemTax->Amount;
                $this->itemList[$n]['ItemTax']['CurrencyCode'] = (string)$item->ItemTax->CurrencyCode;
            }
            if (isset($item->ShippingTax)){
                $this->itemList[$n]['ShippingTax']['Amount'] = (string)$item->ShippingTax->Amount;
                $this->itemList[$n]['ShippingTax']['CurrencyCode'] = (string)$item->ShippingTax->CurrencyCode;
            }
            if (isset($item->GiftWrapTax)){
                $this->itemList[$n]['GiftWrapTax']['Amount'] = (string)$item->GiftWrapTax->Amount;
                $this->itemList[$n]['GiftWrapTax']['CurrencyCode'] = (string)$item->GiftWrapTax->CurrencyCode;
            }
            if (isset($item->ShippingDiscount)){
                $this->itemList[$n]['ShippingDiscount']['Amount'] = (string)$item->ShippingDiscount->Amount;
                $this->itemList[$n]['ShippingDiscount']['CurrencyCode'] = (string)$item->ShippingDiscount->CurrencyCode;
            }
            if (isset($item->PromotionDiscount)){
                $this->itemList[$n]['PromotionDiscount']['Amount'] = (string)$item->PromotionDiscount->Amount;
                $this->itemList[$n]['PromotionDiscount']['CurrencyCode'] = (string)$item->PromotionDiscount->CurrencyCode;
            }
            if (isset($item->CODFee)){
                $this->itemList[$n]['CODFee']['Amount'] = (string)$item->CODFee->Amount;
                $this->itemList[$n]['CODFee']['CurrencyCode'] = (string)$item->CODFee->CurrencyCode;
            }
            if (isset($item->CODFeeDiscount)){
                $this->itemList[$n]['CODFeeDiscount']['Amount'] = (string)$item->CODFeeDiscount->Amount;
                $this->itemList[$n]['CODFeeDiscount']['CurrencyCode'] = (string)$item->CODFeeDiscount->CurrencyCode;
            }
            if (isset($item->PromotionIds)){
                $i = 0;
                foreach($item->PromotionIds->children() as $x){
                    $this->itemList[$n]['PromotionIds'][$i] = (string)$x;
                    $i++;
                }
            }
            if (isset($item->InvoiceData)){
                if (isset($item->InvoiceData->InvoiceRequirement)){
                    $this->itemList[$n]['InvoiceData']['InvoiceRequirement'] = (string)$item->InvoiceData->InvoiceRequirement;
                }
                if (isset($item->InvoiceData->BuyerSelectedInvoiceCategory)){
                    $this->itemList[$n]['InvoiceData']['BuyerSelectedInvoiceCategory'] = (string)$item->InvoiceData->BuyerSelectedInvoiceCategory;
                }
                if (isset($item->InvoiceData->InvoiceTitle)){
                    $this->itemList[$n]['InvoiceData']['InvoiceTitle'] = (string)$item->InvoiceData->InvoiceTitle;
                }
                if (isset($item->InvoiceData->InvoiceInformation)){
                    $this->itemList[$n]['InvoiceData']['InvoiceInformation'] = (string)$item->InvoiceData->InvoiceInformation;
                }
            }
            if (isset($item->ConditionId)){
                $this->itemList[$n]['ConditionId'] = (string)$item->ConditionId;
            }
            if (isset($item->ConditionSubtypeId)){
                $this->itemList[$n]['ConditionSubtypeId'] = (string)$item->ConditionSubtypeId;
            }
            if (isset($item->ConditionNote)){
                $this->itemList[$n]['ConditionNote'] = (string)$item->ConditionNote;
            }
            if (isset($item->ScheduledDeliveryStartDate)){
                $this->itemList[$n]['ScheduledDeliveryStartDate'] = (string)$item->ScheduledDeliveryStartDate;
            }
            if (isset($item->ScheduledDeliveryEndDate)){
                $this->itemList[$n]['ScheduledDeliveryEndDate'] = (string)$item->ScheduledDeliveryEndDate;
            }
            $this->index++;
        }
            
    }
1048532
protected function parseXML($xml){
        $this->destinationList = array();
        if (!$xml){
            return false;
        }

        $i = 0;
        foreach ($xml->DestinationList->children() as $item) {
            $this->destinationList[$i]['DeliveryChannel'] = (string)$item->DeliveryChannel;

            foreach ($item->AttributeList->children() as $member) {
                $this->destinationList[$i]['AttributeList'][(string)$member->Key] = (string)$member->Value;
            }

            $i++;
        }
    }
74028
public static function parseResponseIfXml(SimpleXMLElement $xml){
        $returnValue = self::parseElementXml($xml);
        $i = 0;
        $expression = null;
        $responseRules = array();
        foreach($xml->children() as $child){
            if($i){
                $name = $child->getName();
                $methodName = 'parse'.ucfirst($name).'Xml';
                if(method_exists(__CLASS__, $methodName)){
                    $responseRules[] = self::$methodName($child);
                } else{
                    $responseRules[] = self::parseResponseRuleXml($child);
                }
            }else{
                //the first child is the expression
                $expression = self::parseExpressionXml($child);
            }
            $i++;
        }
        $returnValue['expression'] = $expression;
        $returnValue['responseRules'] = $responseRules;
        return $returnValue;
    }
1020527
public function process($xml)
    {
        // Sanitize if necessary:
        if ($this->sanitize) {
            $xml = $this->sanitizeXml($xml);
        }

        // Parse the XML (newer versions of LibXML require a special flag for
        // large documents, and responses may be quite large):
        $flags = LIBXML_VERSION >= 20900 ? LIBXML_PARSEHUGE : 0;
        $oldSetting = libxml_use_internal_errors(true);
        $result = simplexml_load_string($xml, null, $flags);
        $errors = $this->collectXmlErrors();
        libxml_use_internal_errors($oldSetting);
        if (!$result) {
            throw new \Exception('Problem loading XML: ' . $errors);
        }

        // If we got this far, we have a valid response:
        return $result;
    }
1000321
public function dontSeeSoapResponseIncludes($xml)
    {
        $xml = $this->canonicalize($xml);
        $this->assertNotContains($xml, $this->getXmlResponse()->C14N(), "found in XML Response");
    }