Parse GPX data string.
@param $xml
@return GpxFile
549276
public static function parse($xml)
	{
		$xml = simplexml_load_string($xml);

		$gpx = new GpxFile();

		// Parse creator
		$gpx->creator = isset($xml['creator']) ? (string)$xml['creator'] : null;

		// Parse metadata
		$gpx->metadata = isset($xml->metadata) ? MetadataParser::parse($xml->metadata) : null;

		// Parse waypoints
		$gpx->waypoints = isset($xml->wpt) ? WaypointParser::parse($xml->wpt) : [];

		// Parse tracks
		$gpx->tracks = isset($xml->trk) ? TrackParser::parse($xml->trk) : [];

		// Parse routes
		$gpx->routes = isset($xml->rte) ? RouteParser::parse($xml->rte) : [];

		return $gpx;
	}
62534
public static function parse($xml)
    {
        $backup = libxml_disable_entity_loader(true);

        $result = self::normalize(simplexml_load_string(self::sanitize($xml), 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_NOCDATA | LIBXML_NOBLANKS));

        libxml_disable_entity_loader($backup);

        return $result;
    }
274852
final private function parseTrafficData($xml)
    {
        $traffic = [];

        foreach ($xml->channel->item as $item) {
            $item = get_object_vars($item);
            $title = $item['title'];
            $description = $item['description'];
            $pubDate = $item['pubDate'];

            $highway = explode('-', $title, 2)[0];
            $segment = substr(explode('-', $title, 2)[1], 0, -3);
            $direction = substr(explode('-', $title, 2)[1], -2);

            if (empty($traffic[$highway])) $traffic[$highway] = [];
            if (empty($traffic[$highway][$segment])) $traffic[$highway][$segment] = [];

            $traffic[$highway][$segment][$direction] = $description;
            $traffic[$highway][$segment]['pubDate'] = $pubDate;
        }

        return $traffic;
    }
333966
public static function xmlToArray($xml) {
	  // check passed data
    if(!is_string($xml)) {
	    // bad data possed
      throw new LinkedInException('LinkedIn->xmlToArray(): bad data passed, $xml must be a non-zero length string.');
	  }
	  
	  $parser = xml_parser_create();
	  xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
    xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
    if(xml_parse_into_struct($parser, $xml, $tags)) {
	    $elements = array();
      $stack    = array();
      foreach($tags as $tag) {
        $index = count($elements);
        if($tag['type'] == 'complete' || $tag['type'] == 'open') {
          $elements[$tag['tag']]               = array();
          $elements[$tag['tag']]['attributes'] = (array_key_exists('attributes', $tag)) ? $tag['attributes'] : NULL;
          $elements[$tag['tag']]['content']    = (array_key_exists('value', $tag)) ? $tag['value'] : NULL;
          if($tag['type'] == 'open') {
            $elements[$tag['tag']]['children'] = array();
            $stack[count($stack)] = &$elements;
            $elements = &$elements[$tag['tag']]['children'];
          }
        }
        if($tag['type'] == 'close') {
          $elements = &$stack[count($stack) - 1];
          unset($stack[count($stack) - 1]);
        }
      }
      $return_data = $elements;
	  } else {
	    // not valid xml data
	    $return_data = FALSE;
	  }
	  xml_parser_free($parser);
    return $return_data;
  }
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;
	}
534330
public function loadXml($xml)
    {
        if (is_string($xml)) {
            $this->xml = $xml = simplexml_load_string($xml);
        } elseif ($xml instanceof \SimpleXMLElement) {
            $this->xml = $xml;
        }

        $this->addFields($xml);

        return $this;
    }
357346
protected function parseXML($xml) {
        if (!$xml){
            return false;
        }
        if (!$xml->FulfillmentOrder){
            return false;
        }
        if (!$xml->FulfillmentOrderItem){
            return false;
        }
        if (!$xml->FulfillmentShipment){
            return false;
        }
        //Section 1: ShipmentOrder
        $d = $xml->FulfillmentOrder;
        $this->order['Details']['SellerFulfillmentOrderId'] = (string)$d->SellerFulfillmentOrderId;
        $this->order['Details']['MarketplaceId'] = (string)$d->MarketplaceId;
        $this->order['Details']['DisplayableOrderId'] = (string)$d->DisplayableOrderId;
        $this->order['Details']['DisplayableOrderDateTime'] = (string)$d->DisplayableOrderDateTime;
        $this->order['Details']['DisplayableOrderComment'] = (string)$d->DisplayableOrderComment;
        $this->order['Details']['ShippingSpeedCategory'] = (string)$d->ShippingSpeedCategory;
        if (isset($d->DeliveryWindow)) {
            $this->order['Details']['DeliveryWindow']['StartDateTime'] = (string)$d->DeliveryWindow->StartDateTime;
            $this->order['Details']['DeliveryWindow']['EndDateTime'] = (string)$d->DeliveryWindow->EndDateTime;
        }
        $this->order['Details']['DestinationAddress'] = $this->parseAddress($d->DestinationAddress);
        if (isset($d->FulfillmentAction)){
            $this->order['Details']['FulfillmentAction'] = (string)$d->FulfillmentAction;
        }
        if (isset($d->FulfillmentPolicy)){
            $this->order['Details']['FulfillmentPolicy'] = (string)$d->FulfillmentPolicy;
        }
        if (isset($d->FulfillmentMethod)){
            //deprecated
            $this->order['Details']['FulfillmentMethod'] = (string)$d->FulfillmentMethod;
        }
        $this->order['Details']['ReceivedDateTime'] = (string)$d->ReceivedDateTime;
        $this->order['Details']['FulfillmentOrderStatus'] = (string)$d->FulfillmentOrderStatus;
        $this->order['Details']['StatusUpdatedDateTime'] = (string)$d->StatusUpdatedDateTime;
        if (isset($d->NotificationEmailList)){
            $i = 0;
            foreach($d->NotificationEmailList->children() as $x){
                $this->order['Details']['NotificationEmailList'][$i++] = (string)$x;
            }
        }
        if (isset($d->CODSettings->IsCODRequired)){
            $this->order['Details']['CODSettings']['IsCODRequired'] = (string)$d->CODSettings->IsCODRequired;
        }
        if (isset($d->CODSettings->CODCharge)){
            $this->order['Details']['CODSettings']['CODCharge']['CurrencyCode'] = (string)$d->CODSettings->CODCharge->CurrencyCode;
            $this->order['Details']['CODSettings']['CODCharge']['Value'] = (string)$d->CODSettings->CODCharge->Value;
        }
        if (isset($d->CODSettings->CODChargeTax)){
            $this->order['Details']['CODSettings']['CODChargeTax']['CurrencyCode'] = (string)$d->CODSettings->CODChargeTax->CurrencyCode;
            $this->order['Details']['CODSettings']['CODChargeTax']['Value'] = (string)$d->CODSettings->CODChargeTax->Value;
        }
        if (isset($d->CODSettings->ShippingCharge)){
            $this->order['Details']['CODSettings']['ShippingCharge']['CurrencyCode'] = (string)$d->CODSettings->ShippingCharge->CurrencyCode;
            $this->order['Details']['CODSettings']['ShippingCharge']['Value'] = (string)$d->CODSettings->ShippingCharge->Value;
        }
        if (isset($d->CODSettings->ShippingChargeTax)){
            $this->order['Details']['CODSettings']['ShippingChargeTax']['CurrencyCode'] = (string)$d->CODSettings->ShippingChargeTax->CurrencyCode;
            $this->order['Details']['CODSettings']['ShippingChargeTax']['Value'] = (string)$d->CODSettings->ShippingChargeTax->Value;
        }
        
        //Section 2: Order Items
        $i = 0;
        foreach($xml->FulfillmentOrderItem->children() as $x){
            $this->order['Items'][$i]['SellerSKU'] = (string)$x->SellerSKU;
            $this->order['Items'][$i]['SellerFulfillmentOrderItemId'] = (string)$x->SellerFulfillmentOrderItemId;
            $this->order['Items'][$i]['Quantity'] = (string)$x->Quantity;
            if (isset($x->GiftMessage)){
                $this->order['Items'][$i]['GiftMessage'] = (string)$x->GiftMessage;
            }
            if (isset($x->DisplayableComment)){
                $this->order['Items'][$i]['DisplayableComment'] = (string)$x->DisplayableComment;
            }
            if (isset($x->FulfillmentNetworkSKU)){
                $this->order['Items'][$i]['FulfillmentNetworkSKU'] = (string)$x->FulfillmentNetworkSKU;
            }
            if (isset($x->OrderItemDisposition)){
                $this->order['Items'][$i]['OrderItemDisposition'] = (string)$x->OrderItemDisposition;
            }
            $this->order['Items'][$i]['CancelledQuantity'] = (string)$x->CancelledQuantity;
            $this->order['Items'][$i]['UnfulfillableQuantity'] = (string)$x->UnfulfillableQuantity;
            if (isset($x->EstimatedShipDateTime)){
                $this->order['Items'][$i]['EstimatedShipDateTime'] = (string)$x->EstimatedShipDateTime;
            }
            if (isset($x->EstimatedArrivalDateTime)){
                $this->order['Items'][$i]['EstimatedArrivalDateTime'] = (string)$x->EstimatedArrivalDateTime;
            }
            if (isset($x->PerUnitDeclaredValue)){
                $this->order['Items'][$i]['PerUnitDeclaredValue']['CurrencyCode'] = (string)$x->PerUnitDeclaredValue->CurrencyCode;
                $this->order['Items'][$i]['PerUnitDeclaredValue']['Value'] = (string)$x->PerUnitDeclaredValue->Value;
            }
            if (isset($x->PerUnitPrice)){
                $this->order['Items'][$i]['PerUnitPrice']['CurrencyCode'] = (string)$x->PerUnitPrice->CurrencyCode;
                $this->order['Items'][$i]['PerUnitPrice']['Value'] = (string)$x->PerUnitPrice->Value;
            }
            if (isset($x->PerUnitTax)){
                $this->order['Items'][$i]['PerUnitTax']['CurrencyCode'] = (string)$x->PerUnitTax->CurrencyCode;
                $this->order['Items'][$i]['PerUnitTax']['Value'] = (string)$x->PerUnitTax->Value;
            }
            $i++;
        }
        
        //Section 3: Order Shipments
        $i = 0;
        foreach($xml->FulfillmentShipment->children() as $x){
            $this->order['Shipments'][$i]['AmazonShipmentId'] = (string)$x->AmazonShipmentId;
            $this->order['Shipments'][$i]['FulfillmentCenterId'] = (string)$x->FulfillmentCenterId;
            $this->order['Shipments'][$i]['FulfillmentShipmentStatus'] = (string)$x->FulfillmentShipmentStatus;
            if (isset($x->ShippingDateTime)){
                $this->order['Shipments'][$i]['ShippingDateTime'] = (string)$x->ShippingDateTime;
            }
            if (isset($x->EstimatedArrivalDateTime)){
                $this->order['Shipments'][$i]['EstimatedArrivalDateTime'] = (string)$x->EstimatedArrivalDateTime;
            }
            //FulfillmentShipmentItem
            $j = 0;
            foreach ($x->FulfillmentShipmentItem->children() as $y){
                if (isset($y->SellerSKU)){
                    $this->order['Shipments'][$i]['FulfillmentShipmentItem'][$j]['SellerSKU'] = (string)$y->SellerSKU;
                }
                $this->order['Shipments'][$i]['FulfillmentShipmentItem'][$j]['SellerFulfillmentOrderItemId'] = (string)$y->SellerFulfillmentOrderItemId;
                $this->order['Shipments'][$i]['FulfillmentShipmentItem'][$j]['Quantity'] = (string)$y->Quantity;
                if (isset($y->PackageNumber)){
                    $this->order['Shipments'][$i]['FulfillmentShipmentItem'][$j]['PackageNumber'] = (string)$y->PackageNumber;
                }
                $j++;
            }
            if (isset($x->FulfillmentShipmentPackage)){
                $j = 0;
                foreach ($x->FulfillmentShipmentPackage->children() as $y){
                    $this->order['Shipments'][$i]['FulfillmentShipmentPackage'][$j]['PackageNumber'] = (string)$y->PackageNumber;
                    $this->order['Shipments'][$i]['FulfillmentShipmentPackage'][$j]['CarrierCode'] = (string)$y->CarrierCode;
                    if (isset($y->TrackingNumber)){
                        $this->order['Shipments'][$i]['FulfillmentShipmentPackage'][$j]['TrackingNumber'] = (string)$y->TrackingNumber;
                    }
                    if (isset($y->EstimatedArrivalDateTime)){
                        $this->order['Shipments'][$i]['FulfillmentShipmentPackage'][$j]['EstimatedArrivalDateTime'] = (string)$y->EstimatedArrivalDateTime;
                    }
                    $j++;
                }
            }
            
            $i++;
        }

        //Section 4: Return Items
        if (isset($xml->ReturnItemList)) {
            foreach ($xml->ReturnItemList->children() as $x) {
                $temp = array();
                $temp['SellerReturnItemId'] = (string)$x->SellerReturnItemId;
                $temp['SellerFulfillmentOrderItemId'] = (string)$x->SellerFulfillmentOrderItemId;
                $temp['AmazonShipmentId'] = (string)$x->AmazonShipmentId;
                $temp['SellerReturnReasonCode'] = (string)$x->SellerReturnReasonCode;
                if (isset($x->ReturnComment)) {
                    $temp['ReturnComment'] = (string)$x->ReturnComment;
                }
                if (isset($x->AmazonReturnReasonCode)) {
                    $temp['AmazonReturnReasonCode'] = (string)$x->AmazonReturnReasonCode;
                }
                $temp['Status'] = (string)$x->Status;
                $temp['StatusChangedDate'] = (string)$x->StatusChangedDate;
                if (isset($x->ReturnAuthorizationId)) {
                    $temp['ReturnAuthorizationId'] = (string)$x->ReturnAuthorizationId;
                }
                if (isset($x->ReturnReceivedCondition)) {
                    $temp['ReturnReceivedCondition'] = (string)$x->ReturnReceivedCondition;
                }
                if (isset($x->FulfillmentCenterId)) {
                    $temp['FulfillmentCenterId'] = (string)$x->FulfillmentCenterId;
                }
                $this->order['ReturnItems'][] = $temp;
            }
        }

        //Section 5: Return Authorizations
        if (isset($xml->ReturnAuthorizationList)) {
            foreach ($xml->ReturnAuthorizationList->children() as $x) {
                $temp = array();
                $temp['ReturnAuthorizationId'] = (string)$x->ReturnAuthorizationId;
                $temp['FulfillmentCenterId'] = (string)$x->FulfillmentCenterId;
                $temp['ReturnToAddress'] = $this->parseAddress($x->ReturnToAddress);
                $temp['AmazonRmaId'] = (string)$x->AmazonRmaId;
                $temp['RmaPageURL'] = (string)$x->RmaPageURL;
                $this->order['ReturnAuthorizations'][] = $temp;
            }
        }
    }
50242
private function parseXml( SimpleXMLElement $xml )
    {
        $schema = array();

        foreach ( $xml->table as $table )
        {
            $tableName = (string) $table->name;
            $schema[$tableName] = $this->parseTable( $table );
        }

        return new ezcDbSchema( $schema );
    }
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;
    }
1150036
protected function parseXML($xml)
    {
        $xmlObject = simplexml_load_string($xml);

        // // this wil generate a date like '2018-06-01' for the last updated date for the rates - we do not implement this now
        // $updatedDate = ((array) $xmlObject->Cube->Cube->attributes())['@attributes']['time'];

        $pairs = array();

        // @codingStandardsIgnoreLine
        foreach ($xmlObject->Cube->Cube->children() as $rateObject) {
            $attributes = (array) $rateObject->attributes();
            $pairs[$attributes['@attributes']['currency']] = $attributes['@attributes']['rate'];
        }

        return $pairs;
    }
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);
            }
        }
    }
1138286
protected function parseXml($xml) {
        if (!$xml){
            return false;
        }

        //response from send, confirm, estimate, void
        if (isset($xml->TransportResult->TransportStatus)) {
            $this->status = (string)$xml->TransportResult->TransportStatus;
        }
        //response from get
        if (isset($xml->TransportContent)) {
            $this->contents = array();
            $this->status = (string)$xml->TransportContent->TransportResult->TransportStatus;
            $this->contents['SellerId'] = (string)$xml->TransportContent->TransportHeader->SellerId;
            $this->contents['ShipmentId'] = (string)$xml->TransportContent->TransportHeader->ShipmentId;
            $this->contents['IsPartnered'] = (string)$xml->TransportContent->TransportHeader->IsPartnered;
            $this->contents['ShipmentType'] = (string)$xml->TransportContent->TransportHeader->ShipmentType;

            //one of four possible response structures for details
            $this->contents['Details'] = array();
            $d = array();
            if (isset($xml->TransportContent->TransportDetails->PartneredSmallParcelData)) {
                //Partnered + SP
                $d = $xml->TransportContent->TransportDetails->PartneredSmallParcelData;
            } else if (isset($xml->TransportContent->TransportDetails->NonPartneredSmallParcelData)) {
                //Non-Partnered + SP
                $d = $xml->TransportContent->TransportDetails->NonPartneredSmallParcelData;
            } else if (isset($xml->TransportContent->TransportDetails->PartneredLtlData)) {
                //Partnered + LTL
                $d = $xml->TransportContent->TransportDetails->PartneredLtlData;
                $this->contents['Details']['Contact']['Name'] = (string)$d->Contact->Name;
                $this->contents['Details']['Contact']['Phone'] = (string)$d->Contact->Phone;
                $this->contents['Details']['Contact']['Email'] = (string)$d->Contact->Email;
                $this->contents['Details']['Contact']['Fax'] = (string)$d->Contact->Fax;
                $this->contents['Details']['BoxCount'] = (string)$d->BoxCount;
                if (isset($d->SellerFreightClass)) {
                    $this->contents['Details']['SellerFreightClass'] = (string)$d->SellerFreightClass;
                }
                $this->contents['Details']['FreightReadyDate'] = (string)$d->FreightReadyDate;
                foreach ($d->PalletList->children() as $x) {
                    $temp = array();
                    $temp['IsStacked'] = (string)$x->IsStacked;
                    $temp['Dimensions']['Unit'] = (string)$x->Dimensions->Unit;
                    $temp['Dimensions']['Length'] = (string)$x->Dimensions->Length;
                    $temp['Dimensions']['Width'] = (string)$x->Dimensions->Width;
                    $temp['Dimensions']['Height'] = (string)$x->Dimensions->Height;
                    if (isset($x->Weight)) {
                        $temp['Weight']['Value'] = (string)$x->Weight->Value;
                        $temp['Weight']['Unit'] = (string)$x->Weight->Unit;
                    }
                    $this->contents['Details']['PalletList'][] = $temp;
                }
                $this->contents['Details']['TotalWeight']['Value'] = (string)$d->TotalWeight->Value;
                $this->contents['Details']['TotalWeight']['Unit'] = (string)$d->TotalWeight->Unit;
                if (isset($d->SellerDeclaredValue)) {
                    $this->contents['Details']['SellerDeclaredValue']['Value'] = (string)$d->SellerDeclaredValue->Value;
                    $this->contents['Details']['SellerDeclaredValue']['CurrencyCode'] = (string)$d->SellerDeclaredValue->CurrencyCode;
                }
                if (isset($d->AmazonCalculatedValue)) {
                    $this->contents['Details']['AmazonCalculatedValue']['Value'] = (string)$d->AmazonCalculatedValue->Value;
                    $this->contents['Details']['AmazonCalculatedValue']['CurrencyCode'] = (string)$d->AmazonCalculatedValue->CurrencyCode;
                }
                $this->contents['Details']['PreviewPickupDate'] = (string)$d->PreviewPickupDate;
                $this->contents['Details']['PreviewDeliveryDate'] = (string)$d->PreviewDeliveryDate;
                $this->contents['Details']['PreviewFreightClass'] = (string)$d->PreviewFreightClass;
                $this->contents['Details']['AmazonReferenceId'] = (string)$d->AmazonReferenceId;
                $this->contents['Details']['IsBillOfLadingAvailable'] = (string)$d->IsBillOfLadingAvailable;
                $this->contents['Details']['CarrierName'] = (string)$d->CarrierName;
            } else if (isset($xml->TransportContent->TransportDetails->NonPartneredLtlData)) {
                //Non-Partnered + LTL
                $d = $xml->TransportContent->TransportDetails->NonPartneredLtlData;
                $this->contents['Details']['CarrierName'] = (string)$d->CarrierName;
                $this->contents['Details']['ProNumber'] = (string)$d->ProNumber;
            }
            //shared by both SP structures
            if (isset($d->PackageList)) {
                foreach ($d->PackageList->children() as $x) {
                    $temp = array();
                    $temp['TrackingId'] = (string)$x->TrackingId;
                    $temp['PackageStatus'] = (string)$x->PackageStatus;
                    $temp['CarrierName'] = (string)$x->CarrierName;
                    if (isset($x->Weight)) {
                        $temp['Weight']['Value'] = (string)$x->Weight->Value;
                        $temp['Weight']['Unit'] = (string)$x->Weight->Unit;
                    }
                    if (isset($x->Dimensions)) {
                        $temp['Dimensions']['Unit'] = (string)$x->Dimensions->Unit;
                        $temp['Dimensions']['Length'] = (string)$x->Dimensions->Length;
                        $temp['Dimensions']['Width'] = (string)$x->Dimensions->Width;
                        $temp['Dimensions']['Height'] = (string)$x->Dimensions->Height;
                    }
                    $this->contents['Details']['PackageList'][] = $temp;
                }
            }
            //shared by both partnered structures
            if (isset($d->PartneredEstimate)) {
                $pe = array();
                $pe['Amount']['Value'] = (string)$d->PartneredEstimate->Amount->Value;
                $pe['Amount']['CurrencyCode'] = (string)$d->PartneredEstimate->Amount->CurrencyCode;
                if (isset($d->PartneredEstimate->ConfirmDeadline)) {
                    $pe['ConfirmDeadline'] = (string)$d->PartneredEstimate->ConfirmDeadline;
                }
                if (isset($d->PartneredEstimate->ConfirmDeadline)) {
                    $pe['VoidDeadline'] = (string)$d->PartneredEstimate->VoidDeadline;
                }
                $this->contents['Details']['PartneredEstimate'] = $pe;
            }
        }
    }
640898
protected function parseFeeDetail($xml){
        $r = array();
        $r['FeeType'] = (string)$xml->FeeType;
        $r['FeeAmount'] = $this->parseMoney($xml->FeeAmount);
        if (isset($xml->FeePromotion)){
            $r['FeePromotion'] = $this->parseMoney($xml->FeePromotion);
        }
        if (isset($xml->TaxAmount)){
            $r['TaxAmount'] = $this->parseMoney($xml->TaxAmount);
        }
        $r['FinalFee'] = $this->parseMoney($xml->FinalFee);
        if (isset($xml->IncludedFeeDetailList)){
            $r['IncludedFeeDetailList'] = array();
            foreach($xml->IncludedFeeDetailList->children() as $x){
                $r['IncludedFeeDetailList'][] = $this->parseFeeDetail($x);
            }
        }
        return $r;
    }
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++;
            }
        }
    }
1288348
public static function parse($data)
    {
        $xml = null;
        if ($xml = simplexml_load_string($data)) {
            $xml = (array)$xml;
        }
        return $xml;
    }
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++;
        }
    }
1094448
protected function parseXml($xml) {
        if (!$xml || !$xml->FinancialEventGroupList) {
            return false;
        }
        foreach($xml->FinancialEventGroupList->children() as $x) {
            $temp = array();
            $temp['FinancialEventGroupId'] = (string)$x->FinancialEventGroupId;
            $temp['ProcessingStatus'] = (string)$x->ProcessingStatus;
            if (isset($x->FundTransferStatus)) {
                $temp['FundTransferStatus'] = (string)$x->FundTransferStatus;
            }
            $temp['OriginalTotal']['Amount'] = (string)$x->OriginalTotal->CurrencyAmount;
            $temp['OriginalTotal']['CurrencyCode'] = (string)$x->OriginalTotal->CurrencyCode;
            if (isset($x->ConvertedTotal)) {
                $temp['ConvertedTotal']['Amount'] = (string)$x->ConvertedTotal->CurrencyAmount;
                $temp['ConvertedTotal']['CurrencyCode'] = (string)$x->ConvertedTotal->CurrencyCode;
            }
            if (isset($x->FundTransferDate)) {
                $temp['FundTransferDate'] = (string)$x->FundTransferDate;
            }
            if (isset($x->TraceId)) {
                $temp['TraceId'] = (string)$x->TraceId;
            }
            if (isset($x->AccountTail)) {
                $temp['AccountTail'] = (string)$x->AccountTail;
            }
            $temp['BeginningBalance']['Amount'] = (string)$x->BeginningBalance->CurrencyAmount;
            $temp['BeginningBalance']['CurrencyCode'] = (string)$x->BeginningBalance->CurrencyCode;
            $temp['FinancialEventGroupStart'] = (string)$x->FinancialEventGroupStart;
            if (isset($x->FinancialEventGroupEnd)) {
                $temp['FinancialEventGroupEnd'] = (string)$x->FinancialEventGroupEnd;
            }
            $this->list[$this->index] = $temp;
            $this->index++;
        }
    }