Jump to content
  • Checkout
  • Login
  • Get in touch


The e-commerce.

UPS XML Time in Transit -HELP!


Recommended Posts

I am trying to update the UPS XML contribution to include Ground Time in Transit.


I have it returning the XML response from UPS. However, I cannot parse it properly. Can someone tell me why my function is not returning the number of days?


I am a newbie at PHP and UPS will not provide programming help.


Here is the response which is returned from UPS:


<?xml version="1.0"?>




<CustomerContext>TNT_D Origin Country Code</CustomerContext>












<Country>UNITED STATES</Country>









<Country>UNITED STATES</Country>











<Disclaimer>All services are guaranteed if shipment is paid for in full by a payee

in the United States. Services listed as guaranteed are backed by a money-back

guarantee for transportation charges only. See Terms and Conditions in the Service

Guide for details. Certain commoditites and high value shipments may require

additional transit time for customs clearance.</Disclaimer>




<Description>UPS Ground</Description>




















Here is my parsing function:


// Parse XML message returned by the UPS post server.

function _transitparseResult($xmlResult) {

$doc = new XMLDocument();

$xp = new XMLParser();



$doc = $xp->getDocument();


// Get version. Must be xpci version 1.0001 or this might not work.

$responseVersion = $doc->getValueByPath('TimeInTransitResponse/Response/TransactionReference/XpciVersion');

if ($this->transitxpci_version != $responseVersion) {


return $message;



// Get response code. 1 = SUCCESS, 0 = FAIL

$responseStatusCode = $doc->getValueByPath('TimeInTransitResponse/Response/ResponseStatusCode');


if ($responseStatusCode != '1') {

$errorMsg = $doc->getValueByPath('TimeInTransitResponse/Response/Error/ErrorCode');

$errorMsg .= ": ";

$errorMsg .= $doc->getValueByPath('TimeInTransitResponse/Response/Error/ErrorDescription');

return $errorMsg;



$root = $doc->getRoot();

$serviceSummary = $root->getElementsByName("ServiceSummary");

for ($i = 0; $i < count($serviceSummary); $i++) {

$serviceCode = $serviceSummary[$i]->getValueByPath("Service/Code");

$timetransit = $serviceSummary[$i]->getValueByPath("EstimatedArrive/BusinessTransitDays");

if (!($serviceCode)) {



if ($serviceCode="GND"){

$gndtransit = $timetransit;



return $gndtransit;



The function works until I get to the line beginning $serviceSummary.


Any ideas?




Donna Gordon


Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...