I've successfully implemented the UPS tracking API but the response is a complex xml file and I only need basic data from it. I need the status descriptions, dates and times and the delivery address.
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<trk:TrackResponse
xmlns:trk="http://www.ups.com/XMLSchema/XOLTWS/Track/v2.0">
<common:Response
xmlns:common="http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0">
<common:ResponseStatus>
<common:Code>1</common:Code>
<common:Description>Success</common:Description>
</common:ResponseStatus>
<common:TransactionReference>
<common:CustomerContext>track order</common:CustomerContext>
</common:TransactionReference>
</common:Response>
<trk:Shipment>
<trk:InquiryNumber>
<trk:Code>01</trk:Code>
<trk:Description>ShipmentIdentificationNumber</trk:Description>
<trk:Value>1ZA474A76843297635</trk:Value>
</trk:InquiryNumber>
<trk:ShipperNumber>A474A7</trk:ShipperNumber>
<trk:ShipmentAddress>
<trk:Type>
<trk:Code>01</trk:Code>
<trk:Description>Shipper Address</trk:Description>
</trk:Type>
<trk:Address>
<trk:AddressLine>GRANGEFIELD IND EST</trk:AddressLine>
<trk:City>LEEDS</trk:City>
<trk:PostalCode>LS28 6QW</trk:PostalCode>
<trk:CountryCode>GB</trk:CountryCode>
</trk:Address>
</trk:ShipmentAddress>
<trk:ShipmentAddress>
<trk:Type>
<trk:Code>02</trk:Code>
<trk:Description>ShipTo Address</trk:Description>
</trk:Type>
<trk:Address>
<trk:AddressLine>75086</trk:AddressLine>
<trk:AddressLine>ROCKLINE INDUSTRIES LTD</trk:AddressLine>
<trk:AddressLine>HEMING ROAD</trk:AddressLine>
<trk:City>REDDITCH</trk:City>
<trk:PostalCode>B98 0DH</trk:PostalCode>
<trk:CountryCode>GB</trk:CountryCode>
</trk:Address>
</trk:ShipmentAddress>
<trk:ShipmentWeight>
<trk:UnitOfMeasurement>
<trk:Code>KGS</trk:Code>
</trk:UnitOfMeasurement>
<trk:Weight>1.00</trk:Weight>
</trk:ShipmentWeight>
<trk:Service>
<trk:Code>011</trk:Code>
<trk:Description>UPS Standard</trk:Description>
</trk:Service>
<trk:ReferenceNumber>
<trk:Code>16</trk:Code>
<trk:Value>757142/1</trk:Value>
</trk:ReferenceNumber>
<trk:ReferenceNumber>
<trk:Code>17</trk:Code>
<trk:Value>75086</trk:Value>
</trk:ReferenceNumber>
<trk:PickupDate>20230118</trk:PickupDate>
<trk:Package>
<trk:TrackingNumber>1ZA474A76843297635</trk:TrackingNumber>
<trk:PackageServiceOption>
<trk:Type>
<trk:Code>030</trk:Code>
<trk:Description>Hazardous Materials</trk:Description>
</trk:Type>
</trk:PackageServiceOption>
<trk:Activity>
<trk:ActivityLocation>
<trk:Address>
<trk:AddressLine>THE WASHFORD INDUSTRIAL EST</trk:AddressLine>
<trk:City>REDDITCH</trk:City>
<trk:PostalCode>B98 0DH</trk:PostalCode>
<trk:CountryCode>GB</trk:CountryCode>
</trk:Address>
<trk:Code>M4</trk:Code>
<trk:Description>Reception</trk:Description>
<trk:SignedForByName>DAWN</trk:SignedForByName>
</trk:ActivityLocation>
<trk:Status>
<trk:Type>D</trk:Type>
<trk:Description>Delivered</trk:Description>
<trk:Code>9E</trk:Code>
</trk:Status>
<trk:Date>20230119</trk:Date>
<trk:Time>095320</trk:Time>
<trk:Document>
<trk:Type>
<trk:Code>04</trk:Code>
<trk:Description>POD Letter</trk:Description>
</trk:Type>
<trk:Content>PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwvL0VOIj48SFRNTD48SEVBRD48TUVUQSBIVFRQLUVRVUlWPSJDb250ZW50LVR5cGUiIENPTlRFTlQ9InRleHQvaHRtbDsgY2hhcnNldD1JU08tODg1OS0xIj48VElUTE0RZPjwvSFRNTD4=</trk:Content>
<trk:Format>
<trk:Code>03</trk:Code>
<trk:Description>HTML</trk:Description>
</trk:Format>
</trk:Document>
</trk:Activity>
<trk:Activity>
<trk:ActivityLocation>
<trk:Address>
<trk:City>Tamworth</trk:City>
<trk:CountryCode>GB</trk:CountryCode>
</trk:Address>
<trk:Description>Reception</trk:Description>
</trk:ActivityLocation>
<trk:Status>
<trk:Type>I</trk:Type>
<trk:Description>Out For Delivery</trk:Description>
<trk:Code>OF</trk:Code>
</trk:Status>
<trk:Date>20230119</trk:Date>
<trk:Time>052200</trk:Time>
</trk:Activity>
<trk:Activity>
<trk:ActivityLocation>
<trk:Address>
<trk:City>Tamworth</trk:City>
<trk:CountryCode>GB</trk:CountryCode>
</trk:Address>
<trk:Description>Reception</trk:Description>
</trk:ActivityLocation>
<trk:Status>
<trk:Type>I</trk:Type>
<trk:Description>Arrived at Facility</trk:Description>
<trk:Code>AR</trk:Code>
</trk:Status>
<trk:Date>20230119</trk:Date>
<trk:Time>013700</trk:Time>
</trk:Activity>
<trk:Activity>
<trk:ActivityLocation>
<trk:Address>
<trk:City>Preston</trk:City>
<trk:CountryCode>GB</trk:CountryCode>
</trk:Address>
<trk:Description>Reception</trk:Description>
</trk:ActivityLocation>
<trk:Status>
<trk:Type>I</trk:Type>
<trk:Description>Departed from Facility</trk:Description>
<trk:Code>DP</trk:Code>
</trk:Status>
<trk:Date>20230118</trk:Date>
<trk:Time>233000</trk:Time>
</trk:Activity>
<trk:Activity>
<trk:ActivityLocation>
<trk:Address>
<trk:City>Preston</trk:City>
<trk:CountryCode>GB</trk:CountryCode>
</trk:Address>
<trk:Description>Reception</trk:Description>
</trk:ActivityLocation>
<trk:Status>
<trk:Type>I</trk:Type>
<trk:Description>Arrived at Facility</trk:Description>
<trk:Code>AR</trk:Code>
</trk:Status>
<trk:Date>20230118</trk:Date>
<trk:Time>214500</trk:Time>
</trk:Activity>
<trk:Activity>
<trk:ActivityLocation>
<trk:Address>
<trk:City>Leeds</trk:City>
<trk:CountryCode>GB</trk:CountryCode>
</trk:Address>
<trk:Description>Reception</trk:Description>
</trk:ActivityLocation>
<trk:Status>
<trk:Type>I</trk:Type>
<trk:Description>Departed from Facility</trk:Description>
<trk:Code>DP</trk:Code>
</trk:Status>
<trk:Date>20230118</trk:Date>
<trk:Time>204000</trk:Time>
</trk:Activity>
<trk:Activity>
<trk:ActivityLocation>
<trk:Address>
<trk:City>Leeds</trk:City>
<trk:CountryCode>GB</trk:CountryCode>
</trk:Address>
<trk:Description>Reception</trk:Description>
</trk:ActivityLocation>
<trk:Status>
<trk:Type>I</trk:Type>
<trk:Description>Origin Scan</trk:Description>
<trk:Code>OR</trk:Code>
</trk:Status>
<trk:Date>20230118</trk:Date>
<trk:Time>163413</trk:Time>
</trk:Activity>
<trk:Activity>
<trk:ActivityLocation>
<trk:Address>
<trk:CountryCode>GB</trk:CountryCode>
</trk:Address>
<trk:Description>Reception</trk:Description>
</trk:ActivityLocation>
<trk:Status>
<trk:Type>M</trk:Type>
<trk:Description>Shipper created a label, UPS has not received the package yet.</trk:Description>
<trk:Code>MP</trk:Code>
</trk:Status>
<trk:Date>20230118</trk:Date>
<trk:Time>162032</trk:Time>
</trk:Activity>
<trk:PackageWeight>
<trk:UnitOfMeasurement>
<trk:Code>KGS</trk:Code>
</trk:UnitOfMeasurement>
<trk:Weight>1.00</trk:Weight>
</trk:PackageWeight>
<trk:ReferenceNumber>
<trk:Code>19</trk:Code>
<trk:Value>757142/1</trk:Value>
</trk:ReferenceNumber>
<trk:ReferenceNumber>
<trk:Code>19</trk:Code>
<trk:Value>75086</trk:Value>
</trk:ReferenceNumber>
</trk:Package>
</trk:Shipment>
</trk:TrackResponse>
</soapenv:Body>
</soapenv:Envelope>
The following code does seem to extract partial data but I don't see how to get the whole records out. Ideally I'd like to extract the records in a html table.
$sxe = new SimpleXMLElement($client->__getLastResponse());
$sxe->registerXPathNamespace('trk', "http://www.ups.com/XMLSchema/XOLTWS/Track/v2.0");
$codes = $sxe->xpath('//trk:AddressLine');
foreach ($codes as $c) {
echo "$c" . "</br>";
}