Parses XML response into array.

This is what reads the response XML and converts it into an array.
@param SimpleXMLElement $xml <p>The XML response from Amazon.</p>
@return boolean <b>FALSE</b> if no XML data is found
167501
protected function parseXML($xml){
        if (!$xml){
            return false;
        }
        
        foreach($xml->children() as $x){
            if($x->getName() == 'ResponseMetadata'){
                continue;
            }
            $temp = (array)$x->attributes();
            if (isset($temp['@attributes']['status']) && $temp['@attributes']['status'] != 'Success'){
                $this->log("Warning: product return was not successful",'Warning');
            }
            if (isset($x->Products)){
                foreach($x->Products->children() as $z){
                    $this->productList[$this->index] = new AmazonProduct($this->storeName, $z, $this->mockMode, $this->mockFiles,$this->config);
                    if (isset($temp['@attributes'])) {
                        $this->productList[$this->index]->data['Identifiers']['Request'] = $temp['@attributes'];
                    }
                    $this->index++;
                }
            } else if (in_array($x->getName(), array('GetProductCategoriesForSKUResult', 'GetProductCategoriesForASINResult',
                    'GetLowestPricedOffersForSKUResult', 'GetLowestPricedOffersForASINResult'))){
                $this->productList[$this->index] = new AmazonProduct($this->storeName, $x, $this->mockMode, $this->mockFiles,$this->config);
                $this->index++;
            } else {
                foreach($x->children() as $z){
                    if($z->getName() == 'Error'){
                        $error = (string)$z->Message;
                        $this->productList['Error'] = $error;
                        $this->log("Product Error: $error",'Warning');
                    } elseif($z->getName() != 'Product'){
                        $this->productList[$z->getName()] = (string)$z;
                        $this->log("Special case: ".$z->getName(),'Warning');
                    } else {
                        $this->productList[$this->index] = new AmazonProduct($this->storeName, $z, $this->mockMode, $this->mockFiles,$this->config);
                        $this->index++;
                    }
                }
            }
        }
    }
473723
protected function parseXML($xml){
        $this->serviceList = array();
        $this->downList = array();
        $this->termsList = array();
        if (!$xml){
            return false;
        }
        if (isset($xml->ShippingServiceList)) {
            $i = 0;
            foreach($xml->ShippingServiceList->children() as $key=>$x){
                if ($key != 'ShippingService'){
                    break;
                }

                $this->serviceList[$i]['ShippingServiceName'] = (string)$x->ShippingServiceName;
                $this->serviceList[$i]['CarrierName'] = (string)$x->CarrierName;
                $this->serviceList[$i]['ShippingServiceId'] = (string)$x->ShippingServiceId;
                $this->serviceList[$i]['ShippingServiceOfferId'] = (string)$x->ShippingServiceOfferId;
                $this->serviceList[$i]['ShipDate'] = (string)$x->ShipDate;
                if (isset($x->EarliestEstimatedDeliveryDate)) {
                    $this->serviceList[$i]['EarliestEstimatedDeliveryDate'] = (string)$x->EarliestEstimatedDeliveryDate;
                }
                if (isset($x->LatestEstimatedDeliveryDate)) {
                    $this->serviceList[$i]['LatestEstimatedDeliveryDate'] = (string)$x->LatestEstimatedDeliveryDate;
                }
                $this->serviceList[$i]['Rate']['Amount'] = (string)$x->Rate->Amount;
                $this->serviceList[$i]['Rate']['CurrencyCode'] = (string)$x->Rate->CurrencyCode;
                $this->serviceList[$i]['ShippingServiceOptions']['DeliveryExperience'] = (string)$x->ShippingServiceOptions->DeliveryExperience;
                $this->serviceList[$i]['ShippingServiceOptions']['CarrierWillPickUp'] = (string)$x->ShippingServiceOptions->CarrierWillPickUp;
                if (isset($x->ShippingServiceOptions->DeclaredValue)) {
                    $this->serviceList[$i]['ShippingServiceOptions']['DeclaredValue']['Amount'] = (string)$x->ShippingServiceOptions->DeclaredValue->Amount;
                    $this->serviceList[$i]['ShippingServiceOptions']['DeclaredValue']['CurrencyCode'] = (string)$x->ShippingServiceOptions->DeclaredValue->CurrencyCode;
                }
                if (isset($x->AvailableLabelFormats)) {
                    foreach ($x->AvailableLabelFormats as $z) {
                        $this->serviceList[$i]['AvailableLabelFormats'][] = (string)$z;
                    }
                }

                $i++;
            }
        }
        if (isset($xml->TemporarilyUnavailableCarrierList)) {
            $i = 0;
            foreach($xml->TemporarilyUnavailableCarrierList->children() as $key=>$x){
                if ($key != 'TemporarilyUnavailableCarrier'){
                    break;
                }

                $this->downList[$i] = (string)$x->CarrierName;
                $i++;
            }
        }
        if (isset($xml->TermsAndConditionsNotAcceptedCarrierList)) {
            $i = 0;
            foreach($xml->TermsAndConditionsNotAcceptedCarrierList->children() as $key=>$x){
                if ($key != 'TermsAndConditionsNotAcceptedCarrier'){
                    break;
                }

                $this->termsList[$i] = (string)$x->CarrierName;
                $i++;
            }
        }
    }
407853
public function toArray(SimpleXMLElement $xml = null)
	{
		if ($xml === null) {
			$xml = $this->xml;
		}

		if (!$xml->children()) {
			return (string) $xml;
		}

		$arr = array();
		foreach ($xml->children() as $tag => $child) {
			if (count($xml->$tag) === 1) {
				$arr[$tag] = $this->toArray($child);
			} else {
				$arr[$tag][] = $this->toArray($child);
			}
		}

		return $arr;
	}
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);
            }
        }
    }
1315490
private function parseXml($xml)
    {
        $priorSetting = libxml_use_internal_errors(true);
        try {
            libxml_clear_errors();
            $xmlPayload = new \SimpleXMLElement($xml);
            if ($error = libxml_get_last_error()) {
                throw new \RuntimeException($error->message);
            }
        } catch (\Exception $e) {
            throw new ParserException("Error parsing XML: {$e->getMessage()}", 0, $e);
        } finally {
            libxml_use_internal_errors($priorSetting);
        }

        return $xmlPayload;
    }
1112385
public function parse( $xml )
	{
		$this->loadXml( $xml );
		$root	= $this->document->firstChild;
		while( $root->nodeType == XML_COMMENT_NODE )
			$root	= $root->nextSibling;

		$tree	= new XML_DOM_Node( $root->nodeName );
		if( $root->hasAttributes())
		{
			$attributeNodes	= $root->attributes;
			foreach( $attributeNodes as $attributeNode )
				$tree->setAttribute( $attributeNode->nodeName, $attributeNode->nodeValue );
		}
		$this->parseRecursive( $root, $tree );
		return $tree;
	}
494451
public static function parseResponseConditionXml(SimpleXMLElement $xml){
        $returnValue = self::parseElementXml($xml);
        foreach($xml->responseIf as $responseIfXml){
            $returnValue['responseIf'] = self::parseResponseIfXml($responseIfXml);
            break;
        }
        foreach($xml->responseElseIf as $responseIfXml){
            if(!isset($returnValue['responseElseIfs'])){
                $returnValue['responseElseIfs'] = array();
            }
            $returnValue['responseElseIfs'][] = self::parseResponseIfXml($responseIfXml);
        }
        foreach($xml->responseElse as $responseIfXml){
            $returnValue['responseElse'] = self::parseResponseElseXml($responseIfXml);
            break;
        }
        return $returnValue;
    }
354579
protected function simpleXmlToArray(SimpleXMLElement $xml) {
		$result = [];
		
		foreach ($xml as $element) {
			$name    = $element->getName();
			$content = get_object_vars($element);
			
			if (isset($content['@attributes'])){
				if (isset($content['@attributes']['value'])) {
					$result[$name] = Std::parseValue($content['@attributes']['value']);
					continue;
				}
				
				unset($content['@attributes']);
			}
			
			if (empty($content)) {
				$result[$name] = Std::parseValue($element);
				continue;
			}
			
			$result[$name] = $this->simpleXmlToArray($element);
		}
		
		return $result;
	}
882662
protected function parseXML($xml) {
        if (!$xml){
            return false;
        }
        $i = 0;
        foreach($xml->children() as $x){
            foreach($x->ShipToAddress->children() as $y => $z){
                $this->planList[$i]['ShipToAddress'][$y] = (string)$z;
                
            }
            $this->planList[$i]['ShipmentId'] = (string)$x->ShipmentId;
            $this->planList[$i]['DestinationFulfillmentCenterId'] = (string)$x->DestinationFulfillmentCenterId;
            $this->planList[$i]['LabelPrepType'] = (string)$x->LabelPrepType;
            $j = 0;
            foreach($x->Items->children() as $y => $z){
                $this->planList[$i]['Items'][$j]['SellerSKU'] = (string)$z->SellerSKU;
                $this->planList[$i]['Items'][$j]['Quantity'] = (string)$z->Quantity;
                $this->planList[$i]['Items'][$j]['FulfillmentNetworkSKU'] = (string)$z->FulfillmentNetworkSKU;
                if (isset($z->PrepDetailsList)) {
                    foreach ($z->PrepDetailsList as $zz) {
                        $temp = array();
                        $temp['PrepInstruction'] = (string)$zz->PrepInstruction;
                        $temp['PrepOwner'] = (string)$zz->PrepOwner;
                        $this->planList[$i]['Items'][$j]['PrepDetailsList'][] = $temp;
                    }
                }
                $j++;
                
            }
            $i++;
        }
    }
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++;
        }
            
    }
934499
public function createResponseFromXml($xml)
    {
        $dom = new \DomDocument($xml);
        if (!$dom->loadXML($xml)) {
            return;
        }

        $data = array();

        foreach($dom->childNodes as $root) {
            if ($root->nodeType !== XML_ELEMENT_NODE) {
                continue;
            }
            foreach($root->childNodes as $node) {
                $name = $node->nodeName;
                $text = $node->textContent;
                $data[$name] = $text;
            }
        }

        return new Response($data);
    }
954345
protected function parseXML($xml) {
        if (!$xml || !$xml->Shipment){
            return false;
        }
        $d = $xml->Shipment;
        $this->data['ShipmentId'] = (string)$d->ShipmentId;
        $this->data['AmazonOrderId'] = (string)$d->AmazonOrderId;
        if (isset($d->SellerOrderId)) {
            $this->data['SellerOrderId'] = (string)$d->SellerOrderId;
        }
        $this->data['Status'] = (string)$d->Status;
        if (isset($d->TrackingId)) {
            $this->data['TrackingId'] = (string)$d->TrackingId;
        }
        $this->data['CreatedDate'] = (string)$d->CreatedDate;
        if (isset($d->LastUpdatedDate)) {
            $this->data['LastUpdatedDate'] = (string)$d->LastUpdatedDate;
        }
        $this->data['Weight']['Value'] = (string)$d->Weight->Value;
        $this->data['Weight']['Unit'] = (string)$d->Weight->Unit;
        $this->data['Insurance']['Amount'] = (string)$d->Insurance->Amount;
        $this->data['Insurance']['CurrencyCode'] = (string)$d->Insurance->CurrencyCode;
        if (isset($d->Label)) {
            $this->data['Label']['Dimensions']['Length'] = (string)$d->Label->Dimensions->Length;
            $this->data['Label']['Dimensions']['Width'] = (string)$d->Label->Dimensions->Width;
            $this->data['Label']['Dimensions']['Unit'] = (string)$d->Label->Dimensions->Unit;
            $this->data['Label']['FileContents']['Contents'] = (string)$d->Label->FileContents->Contents;
            $this->data['Label']['FileContents']['FileType'] = (string)$d->Label->FileContents->FileType;
            $this->data['Label']['FileContents']['Checksum'] = (string)$d->Label->FileContents->Checksum;
            if (isset($d->Label->CustomTextForLabel)) {
                $this->data['Label']['CustomTextForLabel'] = (string)$d->Label->CustomTextForLabel;
            }
            if (isset($d->Label->LabelFormat)) {
                $this->data['Label']['LabelFormat'] = (string)$d->Label->LabelFormat;
            }
            if (isset($d->Label->StandardIdForLabel)) {
                $this->data['Label']['StandardIdForLabel'] = (string)$d->Label->StandardIdForLabel;
            }
        }

        $this->data['ItemList'] = array();
        foreach ($d->ItemList->children() as $x) {
            $temp = array();
            $temp['OrderItemId'] = (string)$x->OrderItemId;
            $temp['Quantity'] = (string)$x->Quantity;
            $this->data['ItemList'][] = $temp;
        }
        if (isset($d->PackageDimensions->Length)) {
            $this->data['PackageDimensions']['Length'] = (string)$d->PackageDimensions->Length;
            $this->data['PackageDimensions']['Width'] = (string)$d->PackageDimensions->Width;
            $this->data['PackageDimensions']['Height'] = (string)$d->PackageDimensions->Height;
            $this->data['PackageDimensions']['Unit'] = (string)$d->PackageDimensions->Unit;
        }
        if (isset($d->PackageDimensions->PredefinedPackageDimensions)) {
            $this->data['PackageDimensions']['PredefinedPackageDimensions'] = (string)$d->PackageDimensions->PredefinedPackageDimensions;
        }

        //Ship From Address
        $this->data['ShipFromAddress']['Name'] = (string)$d->ShipFromAddress->Name;
        $this->data['ShipFromAddress']['AddressLine1'] = (string)$d->ShipFromAddress->AddressLine1;
        if (isset($d->ShipFromAddress->AddressLine3)) {
            $this->data['ShipFromAddress']['AddressLine2'] = (string)$d->ShipFromAddress->AddressLine2;
        }
        if (isset($d->ShipFromAddress->AddressLine3)) {
            $this->data['ShipFromAddress']['AddressLine2'] = (string)$d->ShipFromAddress->AddressLine3;
        }
        if (isset($d->ShipFromAddress->DistrictOrCounty)) {
            $this->data['ShipFromAddress']['DistrictOrCounty'] = (string)$d->ShipFromAddress->DistrictOrCounty;
        }
        $this->data['ShipFromAddress']['Email'] = (string)$d->ShipFromAddress->Email;
        $this->data['ShipFromAddress']['City'] = (string)$d->ShipFromAddress->City;
        if (isset($d->ShipFromAddress->StateOrProvinceCode)) {
            $this->data['ShipFromAddress']['StateOrProvinceCode'] = (string)$d->ShipFromAddress->StateOrProvinceCode;
        }
        $this->data['ShipFromAddress']['PostalCode'] = (string)$d->ShipFromAddress->PostalCode;
        $this->data['ShipFromAddress']['CountryCode'] = (string)$d->ShipFromAddress->CountryCode;
        $this->data['ShipFromAddress']['Phone'] = (string)$d->ShipFromAddress->Phone;

        //Ship To Address
        $this->data['ShipToAddress']['Name'] = (string)$d->ShipToAddress->Name;
        $this->data['ShipToAddress']['AddressLine1'] = (string)$d->ShipToAddress->AddressLine1;
        if (isset($d->ShipToAddress->AddressLine3)) {
            $this->data['ShipToAddress']['AddressLine2'] = (string)$d->ShipToAddress->AddressLine2;
        }
        if (isset($d->ShipToAddress->AddressLine3)) {
            $this->data['ShipToAddress']['AddressLine2'] = (string)$d->ShipToAddress->AddressLine3;
        }
        if (isset($d->ShipToAddress->DistrictOrCounty)) {
            $this->data['ShipToAddress']['DistrictOrCounty'] = (string)$d->ShipToAddress->DistrictOrCounty;
        }
        $this->data['ShipToAddress']['Email'] = (string)$d->ShipToAddress->Email;
        $this->data['ShipToAddress']['City'] = (string)$d->ShipToAddress->City;
        if (isset($d->ShipToAddress->StateOrProvinceCode)) {
            $this->data['ShipToAddress']['StateOrProvinceCode'] = (string)$d->ShipToAddress->StateOrProvinceCode;
        }
        $this->data['ShipToAddress']['PostalCode'] = (string)$d->ShipToAddress->PostalCode;
        $this->data['ShipToAddress']['CountryCode'] = (string)$d->ShipToAddress->CountryCode;
        $this->data['ShipToAddress']['Phone'] = (string)$d->ShipToAddress->Phone;

        //Service
        $this->data['ShippingService']['ShippingServiceName'] = (string)$d->ShippingService->ShippingServiceName;
        $this->data['ShippingService']['CarrierName'] = (string)$d->ShippingService->CarrierName;
        $this->data['ShippingService']['ShippingServiceId'] = (string)$d->ShippingService->ShippingServiceId;
        $this->data['ShippingService']['ShippingServiceOfferId'] = (string)$d->ShippingService->ShippingServiceOfferId;
        $this->data['ShippingService']['ShipDate'] = (string)$d->ShippingService->ShipDate;
        if (isset($d->ShippingService->EarliestEstimatedDeliveryDate)) {
            $this->data['ShippingService']['EarliestEstimatedDeliveryDate'] = (string)$d->ShippingService->EarliestEstimatedDeliveryDate;
        }
        if (isset($d->ShippingService->LatestEstimatedDeliveryDate)) {
            $this->data['ShippingService']['LatestEstimatedDeliveryDate'] = (string)$d->ShippingService->LatestEstimatedDeliveryDate;
        }
        $this->data['ShippingService']['Rate']['Amount'] = (string)$d->ShippingService->Rate->Amount;
        $this->data['ShippingService']['Rate']['CurrencyCode'] = (string)$d->ShippingService->Rate->CurrencyCode;
        $this->data['ShippingService']['DeliveryExperience'] = (string)$d->ShippingService->ShippingServiceOptions->DeliveryExperience;
        $this->data['ShippingService']['CarrierWillPickUp'] = (string)$d->ShippingService->ShippingServiceOptions->CarrierWillPickUp;
        if (isset($d->ShippingService->ShippingServiceOptions->DeclaredValue)) {
            $this->data['ShippingService']['DeclaredValue']['Amount'] = (string)$d->ShippingService->ShippingServiceOptions->DeclaredValue->Amount;
            $this->data['ShippingService']['DeclaredValue']['CurrencyCode'] = (string)$d->ShippingService->ShippingServiceOptions->DeclaredValue->CurrencyCode;
        }
    }
1164724
protected static function xmlToArray(\SimpleXMLElement $xml)/*# : array */
    {
        $arr = array();
        foreach ($xml as $element) {
            $tag = $element->getName();
            $ele = get_object_vars($element);
            if (!empty($ele)) {
                $arr[$tag] = $element instanceof \SimpleXMLElement ?
                    static::xmlToArray($element) :
                    $ele;
            } else {
                $arr[$tag] = trim($element);
            }
        }
        return $arr;
    }
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;
    }
844601
protected function xmlDeserialize($xml)
    {
        $array = [];

        if (!$xml instanceof SimpleXMLElement)
        {
            $xml = new SimpleXMLElement($xml);
        }

        foreach ($xml->children() as $key => $child)
        {
            $value = (string) $child;
            $_children = $this->xmlDeserialize($child);
            $_push = ( $_hasChild = ( count($_children) > 0 ) ) ? $_children : $value;

            if ( $_hasChild && !empty($value) && $value !== '' )
            {
                $_push[] = $value;
            }

            $array[$key] = $_push;
        }

        return $array;
    }
897107
public function parse_xml( $data = null ) {

		if ( ! empty( $data ) ) {
			$this->input = $data;
		}

		$xml = new SimpleXMLElement( $this->input );

		if ( ! isset( $xml->items ) ) {
			return false;
		}

		$data = array(
			'columns' => array(),
			'items'   => array(),
		);

		/**
		 * @var $child      SimpleXMLElement
		 * @var $item_child SimpleXMLElement
		 * @var $data_child SimpleXMLElement
		 */

		if ( isset( $xml->columns ) ) {
			foreach ( $xml->columns->children() as $child ) {
				$sub = $child->getName();

				if ( empty( $sub ) || 'column' !== $sub ) {
					continue;
				}

				if ( isset( $child->name ) ) {
					if ( is_array( $child->name ) ) {
						$column = $child->name[0];
					} else {
						$column = $child->name;
					}

					$data['columns'][] = $column;
				}
			}
		}

		foreach ( $xml->items->children() as $child ) {
			$sub = $child->getName();

			if ( empty( $sub ) || 'item' !== $sub ) {
				continue;
			}

			$item = array();

			$attributes = $child->attributes();

			if ( ! empty( $attributes ) ) {
				foreach ( $attributes as $column => $value ) {
					if ( ! in_array( $column, $data['columns'], true ) ) {
						$data['columns'][] = $column;
					}

					$item[ $column ] = $value;
				}
			}

			$item_child = $child->children();

			if ( ! empty( $item_child ) ) {
				foreach ( $item_child->children() as $data_child ) {
					$column = $data_child->getName();

					if ( ! in_array( $column, $data['columns'], true ) ) {
						$data['columns'][] = $column;
					}

					$item[ $column ] = $item_child->$column;
				}
			}

			if ( ! empty( $item ) ) {
				$data['items'][] = $item;
			}
		}//end foreach

		$this->parsed = $data;

		return $this->parsed;
	}
1048943
protected function xml2object($xml)
    {
        $envelope = simplexml_load_string(
            $xml,
            'SimpleXMLElement',
            0,
            'http://schemas.xmlsoap.org/soap/envelope/'
        );

        foreach ($envelope->Body as $response) {
            $children = $response->children(static::XML_NAMESPACE);
            foreach ($children as $item) {
                return $item;
            }
        }

        throw new Exception('XML from gateway could not be parsed');
    }