Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9001813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:29:11+00:00 2026-06-16T00:29:11+00:00

I have the below XML response from the UPS Rates API and I need

  • 0

I have the below XML response from the UPS Rates API and I need to get the values of ‘ServiceType’, ‘Amount’ and ‘Currency’ nodes for each ‘RateReplyDetails’ only where the RateType node = ‘RATED_ACCOUNT_SHIPMENT’ .

My attempt is below, the ServiceType works but not the amount and currency. Can anyone assist?

$RateReply = $fedex_xml->children("env", true)->Body->children("v13", true)->RateReply;

 foreach($RateReply->RateReplyDetails as $details){
    $service = $details->ServiceType;
    $amount = $details->xpath("/RatedShipmentDetails/ShipmentRateDetail/RateType['RATED_ACCOUNT_SHIPMENT']/TotalNetCharge/Amount");
    $currency = $details->xpath("/RatedShipmentDetails/ShipmentRateDetail/RateType['RATED_ACCOUNT_SHIPMENT']/TotalNetCharge/Currency");

 }

<soapenv:Envelope><env:Header/><env:Body><v13:RateReply><v13:HighestSeverity>SUCCESS</v13:HighestSeverity><v13:Notifications><v13:Severity>SUCCESS</v13:Severity><v13:Source>crs</v13:Source><v13:Code>0</v13:Code><v13:Message>Request was successfully processed. </v13:Message><v13:LocalizedMessage>Request was successfully processed. </v13:LocalizedMessage></v13:Notifications><ns1:TransactionDetail><ns1:CustomerTransactionId> *** Rate Available Services Request v13 using PHP ***</ns1:CustomerTransactionId></ns1:TransactionDetail><ns1:Version><ns1:ServiceId>crs</ns1:ServiceId><ns1:Major>13</ns1:Major><ns1:Intermediate>0</ns1:Intermediate><ns1:Minor>0</ns1:Minor></ns1:Version><v13:RateReplyDetails><v13:ServiceType>INTERNATIONAL_FIRST</v13:ServiceType><v13:PackagingType>YOUR_PACKAGING</v13:PackagingType><v13:DeliveryStation>DKKA </v13:DeliveryStation><v13:DeliveryDayOfWeek>THU</v13:DeliveryDayOfWeek><v13:DeliveryTimestamp>2012-12-13T09:00:00</v13:DeliveryTimestamp><v13:CommitDetails><v13:CommodityName>DOCUMENTS</v13:CommodityName><v13:ServiceType>INTERNATIONAL_FIRST</v13:ServiceType><v13:CommitTimestamp>2012-12-13T09:00:00</v13:CommitTimestamp><v13:DayOfWeek>THU</v13:DayOfWeek><v13:DestinationServiceArea>A4</v13:DestinationServiceArea><v13:BrokerToDestinationDays>0</v13:BrokerToDestinationDays><v13:CommitMessages><v13:Code>134</v13:Code><v13:Message>REQUEST COMPLETED</v13:Message></v13:CommitMessages><v13:DeliveryMessages> 9:00 A.M. IF NO CUSTOMS DELAY</v13:DeliveryMessages><v13:DocumentContent>DOCUMENTS_ONLY</v13:DocumentContent><v13:RequiredDocuments>INTERNATIONAL_AIRWAY_BILL</v13:RequiredDocuments></v13:CommitDetails><v13:DestinationAirportId>BUF</v13:DestinationAirportId><v13:IneligibleForMoneyBackGuarantee>false</v13:IneligibleForMoneyBackGuarantee><v13:OriginServiceArea>AM</v13:OriginServiceArea><v13:DestinationServiceArea>A4</v13:DestinationServiceArea><v13:SignatureOption>INDIRECT</v13:SignatureOption><v13:ActualRateType>PAYOR_ACCOUNT_SHIPMENT</v13:ActualRateType><v13:RatedShipmentDetails><v13:ShipmentRateDetail><v13:RateType>PAYOR_ACCOUNT_SHIPMENT</v13:RateType><v13:RateScale>0000000</v13:RateScale><v13:RateZone>GB001O</v13:RateZone><v13:PricingCode>ACTUAL</v13:PricingCode><v13:RatedWeightMethod>ACTUAL</v13:RatedWeightMethod><v13:CurrencyExchangeRate><v13:FromCurrency>UKL</v13:FromCurrency><v13:IntoCurrency>USD</v13:IntoCurrency><v13:Rate>1.59</v13:Rate></v13:CurrencyExchangeRate><v13:DimDivisor>0</v13:DimDivisor><v13:FuelSurchargePercent>17.5</v13:FuelSurchargePercent><v13:TotalBillingWeight><v13:Units>KG</v13:Units><v13:Value>1.0</v13:Value></v13:TotalBillingWeight><v13:TotalBaseCharge><v13:Currency>USD</v13:Currency><v13:Amount>129.74</v13:Amount></v13:TotalBaseCharge><v13:TotalFreightDiscounts><v13:Currency>USD</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalFreightDiscounts><v13:TotalNetFreight><v13:Currency>USD</v13:Currency><v13:Amount>129.74</v13:Amount></v13:TotalNetFreight><v13:TotalSurcharges><v13:Currency>USD</v13:Currency><v13:Amount>22.71</v13:Amount></v13:TotalSurcharges><v13:TotalNetFedExCharge><v13:Currency>USD</v13:Currency><v13:Amount>152.45</v13:Amount></v13:TotalNetFedExCharge><v13:TotalTaxes><v13:Currency>USD</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalTaxes><v13:TotalNetCharge><v13:Currency>USD</v13:Currency><v13:Amount>152.45</v13:Amount></v13:TotalNetCharge><v13:TotalRebates><v13:Currency>USD</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalRebates><v13:Surcharges><v13:SurchargeType>FUEL</v13:SurchargeType><v13:Description>Fuel</v13:Description><v13:Amount><v13:Currency>USD</v13:Currency><v13:Amount>22.71</v13:Amount></v13:Amount></v13:Surcharges></v13:ShipmentRateDetail></v13:RatedShipmentDetails><v13:RatedShipmentDetails><v13:ShipmentRateDetail><v13:RateType>RATED_ACCOUNT_SHIPMENT</v13:RateType><v13:RateScale>0000000</v13:RateScale><v13:RateZone>GB001O</v13:RateZone><v13:PricingCode>ACTUAL</v13:PricingCode><v13:RatedWeightMethod>ACTUAL</v13:RatedWeightMethod><v13:CurrencyExchangeRate><v13:FromCurrency>UKL</v13:FromCurrency><v13:IntoCurrency>UKL</v13:IntoCurrency><v13:Rate>1.0</v13:Rate></v13:CurrencyExchangeRate><v13:DimDivisor>0</v13:DimDivisor><v13:FuelSurchargePercent>17.5</v13:FuelSurchargePercent><v13:TotalBillingWeight><v13:Units>KG</v13:Units><v13:Value>1.0</v13:Value></v13:TotalBillingWeight><v13:TotalBaseCharge><v13:Currency>UKL</v13:Currency><v13:Amount>81.7</v13:Amount></v13:TotalBaseCharge><v13:TotalFreightDiscounts><v13:Currency>UKL</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalFreightDiscounts><v13:TotalNetFreight><v13:Currency>UKL</v13:Currency><v13:Amount>81.7</v13:Amount></v13:TotalNetFreight><v13:TotalSurcharges><v13:Currency>UKL</v13:Currency><v13:Amount>14.3</v13:Amount></v13:TotalSurcharges><v13:TotalNetFedExCharge><v13:Currency>UKL</v13:Currency><v13:Amount>96.0</v13:Amount></v13:TotalNetFedExCharge><v13:TotalTaxes><v13:Currency>UKL</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalTaxes><v13:TotalNetCharge><v13:Currency>UKL</v13:Currency><v13:Amount>96.0</v13:Amount></v13:TotalNetCharge><v13:TotalRebates><v13:Currency>UKL</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalRebates><v13:Surcharges><v13:SurchargeType>FUEL</v13:SurchargeType><v13:Description>Fuel</v13:Description><v13:Amount><v13:Currency>UKL</v13:Currency><v13:Amount>14.3</v13:Amount></v13:Amount></v13:Surcharges></v13:ShipmentRateDetail></v13:RatedShipmentDetails></v13:RateReplyDetails><v13:RateReplyDetails><v13:ServiceType>INTERNATIONAL_PRIORITY</v13:ServiceType><v13:PackagingType>YOUR_PACKAGING</v13:PackagingType><v13:DeliveryStation>DKKA </v13:DeliveryStation><v13:DeliveryDayOfWeek>THU</v13:DeliveryDayOfWeek><v13:DeliveryTimestamp>2012-12-13T10:30:00</v13:DeliveryTimestamp><v13:CommitDetails><v13:CommodityName>DOCUMENTS</v13:CommodityName><v13:ServiceType>INTERNATIONAL_PRIORITY</v13:ServiceType><v13:CommitTimestamp>2012-12-13T10:30:00</v13:CommitTimestamp><v13:DayOfWeek>THU</v13:DayOfWeek><v13:DestinationServiceArea>A4</v13:DestinationServiceArea><v13:BrokerToDestinationDays>0</v13:BrokerToDestinationDays><v13:CommitMessages><v13:Code>134</v13:Code><v13:Message>REQUEST COMPLETED</v13:Message></v13:CommitMessages><v13:DeliveryMessages>10:30 A.M. IF NO CUSTOMS DELAY</v13:DeliveryMessages><v13:DocumentContent>DOCUMENTS_ONLY</v13:DocumentContent><v13:RequiredDocuments>INTERNATIONAL_AIRWAY_BILL</v13:RequiredDocuments></v13:CommitDetails><v13:DestinationAirportId>BUF</v13:DestinationAirportId><v13:IneligibleForMoneyBackGuarantee>false</v13:IneligibleForMoneyBackGuarantee><v13:OriginServiceArea>AM</v13:OriginServiceArea><v13:DestinationServiceArea>A4</v13:DestinationServiceArea><v13:SignatureOption>INDIRECT</v13:SignatureOption><v13:ActualRateType>PAYOR_ACCOUNT_SHIPMENT</v13:ActualRateType><v13:RatedShipmentDetails><v13:ShipmentRateDetail><v13:RateType>PAYOR_ACCOUNT_SHIPMENT</v13:RateType><v13:RateScale>0000000</v13:RateScale><v13:RateZone>GB001O</v13:RateZone><v13:PricingCode>ACTUAL</v13:PricingCode><v13:RatedWeightMethod>ACTUAL</v13:RatedWeightMethod><v13:CurrencyExchangeRate><v13:FromCurrency>UKL</v13:FromCurrency><v13:IntoCurrency>USD</v13:IntoCurrency><v13:Rate>1.59</v13:Rate></v13:CurrencyExchangeRate><v13:DimDivisor>0</v13:DimDivisor><v13:FuelSurchargePercent>17.5</v13:FuelSurchargePercent><v13:TotalBillingWeight><v13:Units>KG</v13:Units><v13:Value>1.0</v13:Value></v13:TotalBillingWeight><v13:TotalBaseCharge><v13:Currency>USD</v13:Currency><v13:Amount>98.46</v13:Amount></v13:TotalBaseCharge><v13:TotalFreightDiscounts><v13:Currency>USD</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalFreightDiscounts><v13:TotalNetFreight><v13:Currency>USD</v13:Currency><v13:Amount>98.46</v13:Amount></v13:TotalNetFreight><v13:TotalSurcharges><v13:Currency>USD</v13:Currency><v13:Amount>17.23</v13:Amount></v13:TotalSurcharges><v13:TotalNetFedExCharge><v13:Currency>USD</v13:Currency><v13:Amount>115.69</v13:Amount></v13:TotalNetFedExCharge><v13:TotalTaxes><v13:Currency>USD</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalTaxes><v13:TotalNetCharge><v13:Currency>USD</v13:Currency><v13:Amount>115.69</v13:Amount></v13:TotalNetCharge><v13:TotalRebates><v13:Currency>USD</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalRebates><v13:Surcharges><v13:SurchargeType>FUEL</v13:SurchargeType><v13:Description>Fuel</v13:Description><v13:Amount><v13:Currency>USD</v13:Currency><v13:Amount>17.23</v13:Amount></v13:Amount></v13:Surcharges></v13:ShipmentRateDetail></v13:RatedShipmentDetails><v13:RatedShipmentDetails><v13:ShipmentRateDetail><v13:RateType>RATED_ACCOUNT_SHIPMENT</v13:RateType><v13:RateScale>0000000</v13:RateScale><v13:RateZone>GB001O</v13:RateZone><v13:PricingCode>ACTUAL</v13:PricingCode><v13:RatedWeightMethod>ACTUAL</v13:RatedWeightMethod><v13:CurrencyExchangeRate><v13:FromCurrency>UKL</v13:FromCurrency><v13:IntoCurrency>UKL</v13:IntoCurrency><v13:Rate>1.0</v13:Rate></v13:CurrencyExchangeRate><v13:DimDivisor>0</v13:DimDivisor><v13:FuelSurchargePercent>17.5</v13:FuelSurchargePercent><v13:TotalBillingWeight><v13:Units>KG</v13:Units><v13:Value>1.0</v13:Value></v13:TotalBillingWeight><v13:TotalBaseCharge><v13:Currency>UKL</v13:Currency><v13:Amount>62.0</v13:Amount></v13:TotalBaseCharge><v13:TotalFreightDiscounts><v13:Currency>UKL</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalFreightDiscounts><v13:TotalNetFreight><v13:Currency>UKL</v13:Currency><v13:Amount>62.0</v13:Amount></v13:TotalNetFreight><v13:TotalSurcharges><v13:Currency>UKL</v13:Currency><v13:Amount>10.85</v13:Amount></v13:TotalSurcharges><v13:TotalNetFedExCharge><v13:Currency>UKL</v13:Currency><v13:Amount>72.85</v13:Amount></v13:TotalNetFedExCharge><v13:TotalTaxes><v13:Currency>UKL</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalTaxes><v13:TotalNetCharge><v13:Currency>UKL</v13:Currency><v13:Amount>72.85</v13:Amount></v13:TotalNetCharge><v13:TotalRebates><v13:Currency>UKL</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalRebates><v13:Surcharges><v13:SurchargeType>FUEL</v13:SurchargeType><v13:Description>Fuel</v13:Description><v13:Amount><v13:Currency>UKL</v13:Currency><v13:Amount>10.85</v13:Amount></v13:Amount></v13:Surcharges></v13:ShipmentRateDetail></v13:RatedShipmentDetails></v13:RateReplyDetails><v13:RateReplyDetails><v13:ServiceType>INTERNATIONAL_ECONOMY</v13:ServiceType><v13:PackagingType>YOUR_PACKAGING</v13:PackagingType><v13:DeliveryStation>DKKA </v13:DeliveryStation><v13:DeliveryDayOfWeek>MON</v13:DeliveryDayOfWeek><v13:DeliveryTimestamp>2012-12-17T16:30:00</v13:DeliveryTimestamp><v13:CommitDetails><v13:CommodityName>DOCUMENTS</v13:CommodityName><v13:ServiceType>INTERNATIONAL_ECONOMY</v13:ServiceType><v13:CommitTimestamp>2012-12-17T16:30:00</v13:CommitTimestamp><v13:DayOfWeek>MON</v13:DayOfWeek><v13:DestinationServiceArea>A4</v13:DestinationServiceArea><v13:BrokerToDestinationDays>0</v13:BrokerToDestinationDays><v13:CommitMessages><v13:Code>134</v13:Code><v13:Message>REQUEST COMPLETED</v13:Message></v13:CommitMessages><v13:DeliveryMessages> 4:30 P.M. IF NO CUSTOMS DELAY</v13:DeliveryMessages><v13:DocumentContent>DOCUMENTS_ONLY</v13:DocumentContent><v13:RequiredDocuments>INTERNATIONAL_AIRWAY_BILL</v13:RequiredDocuments></v13:CommitDetails><v13:DestinationAirportId>BUF</v13:DestinationAirportId><v13:IneligibleForMoneyBackGuarantee>false</v13:IneligibleForMoneyBackGuarantee><v13:OriginServiceArea>AM</v13:OriginServiceArea><v13:DestinationServiceArea>A4</v13:DestinationServiceArea><v13:SignatureOption>INDIRECT</v13:SignatureOption><v13:ActualRateType>PAYOR_ACCOUNT_SHIPMENT</v13:ActualRateType><v13:RatedShipmentDetails></v13:RatedShipmentDetails><v13:RatedShipmentDetails><v13:ShipmentRateDetail><v13:RateType>RATED_ACCOUNT_SHIPMENT</v13:RateType><v13:RateScale>0000000</v13:RateScale><v13:RateZone>GB001O</v13:RateZone><v13:PricingCode>ACTUAL</v13:PricingCode><v13:RatedWeightMethod>ACTUAL</v13:RatedWeightMethod><v13:CurrencyExchangeRate><v13:FromCurrency>UKL</v13:FromCurrency><v13:IntoCurrency>UKL</v13:IntoCurrency><v13:Rate>1.0</v13:Rate></v13:CurrencyExchangeRate><v13:DimDivisor>0</v13:DimDivisor><v13:FuelSurchargePercent>17.5</v13:FuelSurchargePercent><v13:TotalBillingWeight><v13:Units>KG</v13:Units><v13:Value>1.0</v13:Value></v13:TotalBillingWeight><v13:TotalBaseCharge><v13:Currency>UKL</v13:Currency><v13:Amount>49.7</v13:Amount></v13:TotalBaseCharge><v13:TotalFreightDiscounts><v13:Currency>UKL</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalFreightDiscounts><v13:TotalNetFreight><v13:Currency>UKL</v13:Currency><v13:Amount>49.7</v13:Amount></v13:TotalNetFreight><v13:TotalSurcharges><v13:Currency>UKL</v13:Currency><v13:Amount>8.7</v13:Amount></v13:TotalSurcharges><v13:TotalNetFedExCharge><v13:Currency>UKL</v13:Currency><v13:Amount>58.4</v13:Amount></v13:TotalNetFedExCharge><v13:TotalTaxes><v13:Currency>UKL</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalTaxes><v13:TotalNetCharge><v13:Currency>UKL</v13:Currency><v13:Amount>58.4</v13:Amount></v13:TotalNetCharge><v13:TotalRebates><v13:Currency>UKL</v13:Currency><v13:Amount>0.0</v13:Amount></v13:TotalRebates><v13:Surcharges><v13:SurchargeType>FUEL</v13:SurchargeType><v13:Description>Fuel</v13:Description><v13:Amount><v13:Currency>UKL</v13:Currency><v13:Amount>8.7</v13:Amount></v13:Amount></v13:Surcharges></v13:ShipmentRateDetail></v13:RatedShipmentDetails></v13:RateReplyDetails></v13:RateReply></env:Body></soapenv:Envelope>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:29:12+00:00Added an answer on June 16, 2026 at 12:29 am
    //amount
    "/RatedShipmentDetails/ShipmentRateDetail[RateType = 'RATED_ACCOUNT_SHIPMENT']/TotalNetCharge/Amount"
    
    //currency
    "/RatedShipmentDetails/ShipmentRateDetail[RateType = 'RATED_ACCOUNT_SHIPMENT']/TotalNetCharge/Currency"
    

    see them running here

    sources for xpath: doc examples

    Update

    foreach ($fedex_xml->xpath("//RateReply//RateReplyDetails") as $details) {
    
        $amounts = $details->xpath("./RatedShipmentDetails/ShipmentRateDetail[RateType = 'RATED_ACCOUNT_SHIPMENT']/TotalNetCharge/Amount");
        $currencies = $details->xpath("./RatedShipmentDetails/ShipmentRateDetail[RateType = 'RATED_ACCOUNT_SHIPMENT']/TotalNetCharge/Currency");
    
        var_dump($amounts);
        var_dump($currencies);
    }
    

    I used a xpath expression to select every RateReplyDetails, then used some other xpath expressions to extract the values. Note that the ./ part at the beginning of these are very important, it says interpret the xpath expression in the current scope (RateReplyDetails node).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get following XML string as a response from BING (Note:COMPOSITE result), i tried
I have a XML response from an Ajax REST call. Similar to the one
I have seen the XML response from google checkout when an order is processed
Hello I have an api response in xml format with a series of items
I try to get the token from my fogbugz website, folowing : http://fogbugz.stackexchange.com/fogbugz-xml-api I
I have an XML response as included below. How can I obtain the element?
I have a response that comes from server side in xml format (partial like
I have this certain method(snippet below) for which I want to get the XML
I am using http://blog.frankel.ch/custom-loginmodule-in-tomcat tutorial for tomcat JAASRealm.I have added below in server.xml Realm
I have this below code and it work fine header (content-type: text/xml); $xml =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.