View Full Version : XML - ASP - UPS - Help
mopacfan
May 19th 2004, 2:34 pm
I'm just getting my feet wet with XML. I've been coding html and asp since '95. So any help that anyone can provide will be greatly appreciated. (I started reading the XML Developers Handbook and had to use toothpicks to keep my eyes open)
So here goes, below you'll see some sample code of what UPS returns when I submit a tracking request:
<TrackResponse>
<Response>
<TransactionReference>
<CustomerContext>Mocap1</CustomerContext>
<XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<ResponseStatusCode>1</ResponseStatusCode>
<ResponseStatusDescription>Success</ResponseStatusDescription>
</Response>
<Shipment>
<Shipper>
<ShipperNumber>669668</ShipperNumber>
<Address>
<AddressLine1>111 INDUSTRIAL DR</AddressLine1>
<City>PARK HILLS</City>
<StateProvinceCode>MO</StateProvinceCode>
<PostalCode>63601 3170</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</Shipper>
<ShipTo>
<Address>
<AddressLine1>JACK</AddressLine1>
<AddressLine2>2295 AUTOPLEX DRIVE</AddressLine2>
<City>BOSSIER CITY</City>
<StateProvinceCode>LA</StateProvinceCode>
<PostalCode>71111</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</ShipTo>
<Service>
<Code>003</Code>
<Description>GROUND</Description>
</Service>
<ReferenceNumber>
<Code>01</Code>
<Value>51038</Value>
</ReferenceNumber>
<ReferenceNumber>
<Code>01</Code>
<Value>F15085</Value>
</ReferenceNumber>
<ShipmentIdentificationNumber>1Z6696680305103812</ShipmentIdentificationNumber>
<PickupDate>20040415</PickupDate>
<Package>
<TrackingNumber>1Z6696680305103812</TrackingNumber>
<Activity>
<ActivityLocation>
<Address>
<City>BOSSIER CITY</City>
<StateProvinceCode>LA</StateProvinceCode>
<PostalCode>71111</PostalCode>
<CountryCode>US</CountryCode>
</Address>
<Code>M3</Code>
<Description>FRONT DESK</Description>
<SignedForByName>NORRIS</SignedForByName>
</ActivityLocation>
<Status>
<StatusType>
<Code>D</Code>
<Description>DELIVERED</Description>
</StatusType>
<StatusCode>
<Code>KB</Code>
</StatusCode>
</Status>
<Date>20040419</Date>
<Time>094600</Time>
</Activity>
<Activity>
<ActivityLocation>
<Address>
<City>SHREVEPORT</City>
<StateProvinceCode>LA</StateProvinceCode>
<CountryCode>US</CountryCode>
</Address>
</ActivityLocation>
<Status>
<StatusType>
<Code>I</Code>
<Description>OUT FOR DELIVERY</Description>
</StatusType>
<StatusCode>
<Code>DS</Code>
</StatusCode>
</Status>
<Date>20040419</Date>
<Time>070000</Time>
</Activity>
<Activity>
<ActivityLocation>
<Address>
<City>SHREVEPORT</City>
<StateProvinceCode>LA</StateProvinceCode>
<CountryCode>US</CountryCode>
</Address>
</ActivityLocation>
<Status>
<StatusType>
<Code>I</Code>
<Description>ARRIVAL SCAN</Description>
</StatusType>
<StatusCode>
<Code>AR</Code>
</StatusCode>
</Status>
<Date>20040419</Date>
<Time>060000</Time>
</Activity>
<Activity>
<ActivityLocation>
<Address>
<City>JACKSON</City>
<StateProvinceCode>MS</StateProvinceCode>
<CountryCode>US</CountryCode>
</Address>
</ActivityLocation>
<Status>
<StatusType>
<Code>I</Code>
<Description>DEPARTURE SCAN</Description>
</StatusType>
<StatusCode>
<Code>DP</Code>
</StatusCode>
</Status>
<Date>20040416</Date>
<Time>225500</Time>
</Activity>
<Activity>
<ActivityLocation>
<Address>
<City>JACKSON</City>
<StateProvinceCode>MS</StateProvinceCode>
<CountryCode>US</CountryCode>
</Address>
</ActivityLocation>
<Status>
<StatusType>
<Code>I</Code>
<Description>LOCATION SCAN</Description>
</StatusType>
<StatusCode>
<Code>LC</Code>
</StatusCode>
</Status>
<Date>20040416</Date>
<Time>133756</Time>
... you get the idea.
So what I'm looking for is a way to itterate through the response and display the tracking history to the user. I halfway understand getElementsByTagName(), selectNodes(), etc. My problem is understanding how to get to the activity section and loop through the details in such a way as to present meaningful information to the visitor. Basically, how the heck do you get down to the ActivityLocaion and Status nodes and then regurgiate them?
I hope I made sense with that. It all looks so deceptively simple, but everytime I think I understand how to reference those nodes, blam, I run into a brick wall.
Thanks in advance,
MN
nlopes
May 20th 2004, 7:57 am
Why don't you convert yourself to PHP? :)
With PHP 5, you can do waht you want in 5 minutes with the new module SimpleXML (as it says its very simple!!)
Or you could you XPath and PHP...
In ASP I can't help you....
xml
May 21st 2004, 6:08 am
Have you tride using the nodelist feature?
For example:
Dim myXMLDoc As New DOMDocument
Dim myNodeLst As MSXML.IXMLDOMNodeList
Set myNodeLst = myXMLDoc.getElementsByTagName("Activity")...
For i = 0 to myNodeLst.Count - 1
...Iterate...
Next
Hope this helps
xml
May 21st 2004, 6:17 am
PHP is still lightyears behind the Microsoft XML parser. MSXML is so easy to integrate and its features are complete.
I use PHP only on the web front and I can tell you so far PHP and XML is a let down.
SimpleXML as you say is simple. I'm looking more forward to libxml myself :).
nlopes
May 21st 2004, 6:22 am
I was refering to PHP 5!! It uses the suberb libxml. It's fast, powerfull and easy! ;)
digitalpoint
May 21st 2004, 7:47 am
The XML parser in PHP 4.x always seems to work great (and fast) for whatever I've used it for. Maybe I'm just missing something by not looking at PHP 5 yet. :)
- Shawn
nlopes
May 21st 2004, 7:56 am
In PHP we used the expat library and now we use libXML, which is much faster and powerfull.
And the SimpleXML extension is definetly very powerfull and simple!
digitalpoint
May 21st 2004, 8:01 am
{shrug} Always was fast for me... I can parse a 2GB XML and output it to a CSV file in about 12 minutes.
xml
May 21st 2004, 10:09 am
Once you get some use of libxml you'll understand why it surpasses Expat.
2GB to CVS in 12 mins using Expat is pretty impressive tho, no doubt about that... What was your setup? Quad Xeon 3.2 Ghz's :eek:?
digitalpoint
May 21st 2004, 10:16 am
That was on a dual 1Ghz G4 (Mac).
mcdar
Jun 8th 2004, 10:57 am
Here is asp code that will create a simple dropdown plus a list with your results from UPS.
Just change/add nodes for the information you require.
<%
responsexml = xmlhttp.responseText
Set mydoc=Server.CreateObject("Microsoft.xmlDOM")
mydoc.loadxml(responsexml)
'Create a select table from the response xml
response.Write("<select name='shipping'>")
'Create A Nodelist of All The RatedShipments
Set NodeList = mydoc.documentElement.selectNodes("RatedShipment")
For x = 0 To NodeList.length - 1
'Service/Code
'TotalCharges/MonetaryValue
response.write("<option>")
Response.Write NodeList.Item(x).selectSingleNode("Service/Code").Text & " - $" & NodeList.Item(x).selectSingleNode("TotalCharges/MonetaryValue").Text & " - " & NodeList.Item(x).selectSingleNode("GuaranteedDaysToDelivery").Text
response.write("</option>")
Next
response.Write("</select>")
%>
Caryl
mcdar
Jun 8th 2004, 11:00 am
Actually, here is the entire ASP code for UPS Rates (request and response) if anyone is interested.
<% Response.Buffer=True %>
<%
'dim all of our vars
Dim mydoc, responsexml
'you can build the query dynamically by using request.form or request.querystring, however you want to use it
strXML = "<?xml version='1.0'?><AccessRequest xml:lang='en-US'><AccessLicenseNumber>FBA4C73476F23F62</AccessLicenseNumber><UserId>cmcdar</UserId><Password>biznes1</Password></AccessRequest><?xml version='1.0'?><RatingServiceSelectionRequest xml:lang='en-US'><Request><TransactionReference><CustomerContext>Rating and Service</CustomerContext><XpciVersion>1.0001</XpciVersion></TransactionReference><RequestAction>Rate</RequestAction><RequestOption>shop</RequestOption></Request><PickupType><Code>01</Code></PickupType><Shipment><Shipper><Address><PostalCode>30076</PostalCode></Address></Shipper><ShipTo><Address><PostalCode>30041</PostalCode></Address></ShipTo><Service><Code>11</Code></Service><Package><PackagingType><Code>02</Code><Description>Package</Description></PackagingType><Description>Rate Shopping</Description><PackageWeight><Weight>33</Weight></PackageWeight></Package><ShipmentServiceOptions/></Shipment></RatingServiceSelectionRequest>"
'this will url encode your request
'strXML = Server.UrlEncode(strXML)
'here's where we send the stuff
Dim xmlhttp
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST","https://www.ups.com/ups.app/xml/Rate?",false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send strXML
responsexml = xmlhttp.responseText
Set mydoc=Server.CreateObject("Microsoft.xmlDOM")
mydoc.loadxml(responsexml)
'Create a select table from the response xml
response.Write("<select name='shipping'>")
'Create A Nodelist of All The RatedShipments
Set NodeList = mydoc.documentElement.selectNodes("RatedShipment")
For x = 0 To NodeList.length - 1
'Service/Code
'TotalCharges/MonetaryValue
response.write("<option>")
Response.Write NodeList.Item(x).selectSingleNode("Service/Code").Text & " - $" & NodeList.Item(x).selectSingleNode("TotalCharges/MonetaryValue").Text & " - " & NodeList.Item(x).selectSingleNode("GuaranteedDaysToDelivery").Text
response.write("</option>")
Next
response.Write("</select>")
%>
RoLYroLLs
Jun 13th 2004, 7:21 pm
Hey mopacfan.
I was looking online for a few sample codes for this same exact thing. I had trouble acutally connecting to the track application on ups, but I got that going and now the result I get is "The XML document is not well formed" I have used the sample provided by UPS and and here is how i do the xml doc. Maybe you could help me?
strXML = ""
strXML = strXML & "<?xml version=1.0?>"
strXML = strXML & "<AccessRequest xml:lang=en-US>"
strXML = strXML & "<AccessLicenseNumber>MYACCESSNUMBER</AccessLicenseNumber>"
strXML = strXML & "<Userid>MYUSERID</Userid>"
strXML = strXML & "<Password>MYPASSWORD</Password>"
strXML = strXML & "</AccessRequest>"
strXML = strXML & "<?xml version=1.0?>"
strXML = strXML & "<TrackRequest xml:lang=en-US>"
strXML = strXML & "<Request>"
strXML = strXML & "<TransactionReference>"
strXML = strXML & "<CustomerContext>sample</CustomerContext>"
strXML = strXML & "<XpciVersion>1.0001</XpciVersion>"
strXML = strXML & "</TransactionReference>"
strXML = strXML & "<RequestAction>Track</RequestAction>"
strXML = strXML & "</Request>"
strXML = strXML & "<TrackingNumber>1Z12345E1512345676</TrackingNumber>"
strXML = strXML & "</TrackRequest>"
set objHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
objHttp.open "POST", "https://www.ups.com/ups.app/xml/Track", false
objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.Send strXML
Any ideas?
Thanks!
jongalloway
Jun 27th 2004, 10:39 pm
You need single quotes around your attributes, like en-US:
strXML = strXML & "<?xml version='1.0'?> "
strXML = strXML & "<TrackRequest xml:lang='en-US'> "
strXML = strXML & " <Request> "
strXML = strXML & " <TransactionReference> "
strXML = strXML & " <CustomerContext>Example 1</CustomerContext> "
strXML = strXML & " <XpciVersion>1.0001</XpciVersion> "
strXML = strXML & " </TransactionReference> "
strXML = strXML & " <RequestAction>Track</RequestAction> "
strXML = strXML & " <RequestOption /> "
strXML = strXML & " </Request> "
strXML = strXML & " <TrackingNumber>1ZT9T0000000000000</TrackingNumber> "
strXML = strXML & "</TrackRequest> "
'this will url encode your request
'strXML = Server.UrlEncode(strXML)
'here's where we send the stuff
Dim xmlhttp
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST","https://www.ups.com/ups.app/xml/Track?",false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send strXML
responsexml = xmlhttp.responseText
response.contenttype = "text/xml"
response.write responsexml
ggriffit
Aug 17th 2004, 6:08 am
Hello All,
Looks like the discussion went into PHP stuff and he was asking about XML-ASP-UPS. I am also having the same issue and was wondering if a solution was found.
The solutions shown are for Rates, I am looking for a way to display the tracking. Any examples for that?
Thanks!
mcdar
Aug 17th 2004, 6:22 am
ggriffit,
I have given the actual asp/xml code for UPS rate retrieval 2 posts up!
What exactly are you looking for?
Caryl
ggriffit
Aug 17th 2004, 6:33 am
Cayrl,
I am trying to get Tracking results. I think the example code you displayed above will help me figure things out. At first I did not see the second page of results. If you have a quick sample of how you format the results form the tracking side of things that would be great.
Thanks,
Grant
mcdar
Aug 17th 2004, 7:03 am
Grant,
I have not used the code to retrieve Tracking from UPS. So it would take time to work that out.
But, I just write the XML rate results to my database and have ASP display them from there.
'Create A Nodelist of All The RatedShipments
Set NodeList = mydoc.documentElement.selectNodes("RatedShipment")
ship1=5
getrate="rate"
getratemin="ratemin"
'TotalCharges/MonetaryValue
threeday=(NodeList.Item(1).selectSingleNode("TotalCharges/MonetaryValue").Text)
secday= (NodeList.Item(3).selectSingleNode("TotalCharges/MonetaryValue").Text)
nexsav= (NodeList.Item(4).selectSingleNode("TotalCharges/MonetaryValue").Text)
nexday= (NodeList.Item(6).selectSingleNode("TotalCharges/MonetaryValue").Text)
ship1=6
ship2=7
ship3=8
ship4=9
'Update Shipping Rates in Shipping table in database.
Set rsmod = Server.CreateObject("ADODB.Recordset")
rsmod.Open "Select * From shipping WHERE id=" & ship1, DB, 1, 3
rsmod("rate") = threeday
rsmod.Update
rsmod.Close
Set rsmod = Server.CreateObject("ADODB.Recordset")
rsmod.Open "Select * From shipping WHERE id=" & ship2, DB, 1, 3
rsmod("rate") = secday
rsmod.Update
rsmod.Close
Set rsmod = Server.CreateObject("ADODB.Recordset")
rsmod.Open "Select * From shipping WHERE id=" & ship3, DB, 1, 3
rsmod("rate") = nexsav
rsmod.Update
rsmod.Close
Set rsmod = Server.CreateObject("ADODB.Recordset")
rsmod.Open "Select * From shipping WHERE id=" & ship4, DB, 1, 3
rsmod("rate") = nexday
rsmod.Update
rsmod.Close
Caryl
mopacfan
Aug 17th 2004, 11:37 am
It looks like all these posts are off base. Rolyrolls and ggriffit, if I understand you correctly (since this is what I'm trying to figure out as well), the issue is the data returned from ups when a package is tracked. Not what the rate of shipment is.
Here is the xml that is returned from ups when a request is sent:
<?xml version=""1.0""?>
<TrackResponse>
<Response>
<TransactionReference>
<CustomerContext>Acme</CustomerContext>
<XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<ResponseStatusCode>1</ResponseStatusCode>
<ResponseStatusDescription>Success</ResponseStatusDescription>
</Response>
<Shipment>
<Shipper>
<ShipperNumber>124578</ShipperNumber>
<Address>
<AddressLine1>111 INDUSTRIAL DR</AddressLine1>
<City>Allentown</City>
<StateProvinceCode>MO</StateProvinceCode>
<PostalCode>52487 3170</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</Shipper>
<ShipTo>
<Address>
<AddressLine1>JACK</AddressLine1>
<AddressLine2>2295 AUTOPLEX DRIVE</AddressLine2>
<City>BOSSIER CITY</City>
<StateProvinceCode>LA</StateProvinceCode>
<PostalCode>71111</PostalCode>
<CountryCode>US</CountryCode>
</Address>
</ShipTo>
<Service>
<Code>003</Code>
<Description>GROUND</Description>
</Service>
<ReferenceNumber>
<Code>01</Code>
<Value>51038</Value>
</ReferenceNumber>
<ReferenceNumber>
<Code>01</Code>
<Value>F15085</Value>
</ReferenceNumber>
<ShipmentIdentificationNumber>1Z6696680305102154</ShipmentIdentificationNumber>
<PickupDate>20040415</PickupDate>
<Package>
<TrackingNumber>1Z6696680305102154</TrackingNumber>
<Activity>
<ActivityLocation>
<Address>
<City>BOSSIER CITY</City>
<StateProvinceCode>LA</StateProvinceCode>
<PostalCode>71111</PostalCode>
<CountryCode>US</CountryCode>
</Address>
<Code>M3</Code>
<Description>FRONT DESK</Description>
<SignedForByName>NORRIS</SignedForByName>
</ActivityLocation>
<Status>
<StatusType>
<Code>D</Code>
<Description>DELIVERED</Description>
</StatusType>
<StatusCode>
<Code>KB</Code>
</StatusCode>
</Status>
<Date>20040419</Date>
<Time>094600</Time>
</Activity>
<Activity>
<ActivityLocation>
<Address>
<City>SHREVEPORT</City>
<StateProvinceCode>LA</StateProvinceCode>
<CountryCode>US</CountryCode>
</Address>
</ActivityLocation>
<Status>
<StatusType>
<Code>I</Code>
<Description>OUT FOR DELIVERY</Description>
</StatusType>
<StatusCode>
<Code>DS</Code>
</StatusCode>
</Status>
<Date>20040419</Date>
<Time>070000</Time>
</Activity>
<Activity>
<ActivityLocation>
<Address>
<City>SHREVEPORT</City>
<StateProvinceCode>LA</StateProvinceCode>
<CountryCode>US</CountryCode>
</Address>
</ActivityLocation>
<Status>
<StatusType>
<Code>I</Code>
<Description>ARRIVAL SCAN</Description>
</StatusType>
<StatusCode>
<Code>AR</Code>
</StatusCode>
</Status>
<Date>20040419</Date>
<Time>060000</Time>
</Activity>
<Activity>
<ActivityLocation>
<Address>
<City>JACKSON</City>
<StateProvinceCode>MS</StateProvinceCode>
<CountryCode>US</CountryCode>
</Address>
</ActivityLocation>
<Status>
<StatusType>
<Code>I</Code>
<Description>DEPARTURE SCAN</Description>
</StatusType>
<StatusCode>
<Code>DP</Code>
</StatusCode>
</Status>
<Date>20040416</Date>
<Time>225500</Time>
</Activity>
<Activity>
<ActivityLocation>
<Address>
<City>JACKSON</City>
<StateProvinceCode>MS</StateProvinceCode>
<CountryCode>US</CountryCode>
</Address>
</ActivityLocation>
<Status>
<StatusType>
<Code>I</Code>
<Description>LOCATION SCAN</Description>
</StatusType>
<StatusCode>
<Code>LC</Code>
</StatusCode>
</Status>
<Date>20040416</Date>
<Time>133756</Time>
</Activity><Activity><ActivityLocation><Address><City>JACKSON</City><StateProvinceCode>MS</StateProvinceCode><CountryCode>US</CountryCode></Address></ActivityLocation><Status><StatusType><Code>I</Code><Description>ARRIVAL SCAN</Description></StatusType><StatusCode><Code>AR</Code></StatusCode></Status><Date>20040416</Date><Time>113700</Time></Activity><Activity><ActivityLocation><Address><City>EARTH CITY</City><StateProvinceCode>MO</StateProvinceCode><CountryCode>US</CountryCode></Address></ActivityLocation><Status><StatusType><Code>I</Code><Description>DEPARTURE SCAN</Description></StatusType><StatusCode><Code>DP</Code></StatusCode></Status><Date>20040416</Date><Time>021300</Time></Activity><Activity><ActivityLocation><Address><City>EARTH CITY</City><StateProvinceCode>MO</StateProvinceCode><CountryCode>US</CountryCode></Address></ActivityLocation><Status><StatusType><Code>I</Code><Description>LOCATION SCAN</Description></StatusType><StatusCode><Code>LC</Code></StatusCode></Status><Date>20040415</Date><Time>230844</Time></Activity><Activity><ActivityLocation><Address><City>EARTH CITY</City><StateProvinceCode>MO</StateProvinceCode><CountryCode>US</CountryCode></Address></ActivityLocation><Status><StatusType><Code>I</Code><Description>UNLOAD SCAN</Description></StatusType><StatusCode><Code>UL</Code></StatusCode></Status><Date>20040415</Date><Time>225800</Time></Activity><Activity><ActivityLocation><Address><City>EARTH CITY</City><StateProvinceCode>MO</StateProvinceCode><CountryCode>US</CountryCode></Address></ActivityLocation><Status><StatusType><Code>I</Code><Description>ARRIVAL SCAN</Description></StatusType><StatusCode><Code>AR</Code></StatusCode></Status><Date>20040415</Date><Time>212600</Time></Activity><Activity><ActivityLocation><Address><City>FARMINGTON</City><StateProvinceCode>MO</StateProvinceCode><CountryCode>US</CountryCode></Address></ActivityLocation><Status><StatusType><Code>I</Code><Description>DEPARTURE SCAN</Description></StatusType><StatusCode><Code>DP</Code></StatusCode></Status><Date>20040415</Date><Time>195000</Time></Activity><Activity><ActivityLocation><Address><CountryCode>US</CountryCode></Address></ActivityLocation><Status><StatusType><Code>M</Code><Description>BILLING INFORMATION RECEIVED</Description></StatusType><StatusCode><Code>MP</Code></StatusCode></Status><Date>20040415</Date><Time>190816</Time></Activity><Activity><ActivityLocation><Address><City>FARMINGTON</City><StateProvinceCode>MO</StateProvinceCode><CountryCode>US</CountryCode></Address></ActivityLocation><Status><StatusType><Code>I</Code><Description>ORIGIN SCAN</Description></StatusType><StatusCode><Code>OR</Code></StatusCode></Status><Date>20040415</Date><Time>184440</Time></Activity><PackageWeight><UnitOfMeasurement><Code>LBS</Code></UnitOfMeasurement><Weight>7.00</Weight></PackageWeight><ReferenceNumber><Code>01</Code><Value>51038</Value></ReferenceNumber><ReferenceNumber><Code>01</Code><Value>51038-1 ACCT:F15085 PO# 70325</Value></ReferenceNumber><ReferenceNumber><Code>01</Code><Value>SHIPPED USING (FREIGHT PLUS)</Value></ReferenceNumber><ReferenceNumber><Code>01</Code><Value>SOFTWARE WWW.acme.COM</Value></ReferenceNumber>
</Package>
</Shipment>
</TrackResponse>
If someone has any input into parsing this xml to get the tracking data out of it using ASP, that would be amazing and I would extremely grateful.
mcdar
Aug 17th 2004, 12:09 pm
I do not have time to totally figure this out but here is a sample of the response for UPS Rates that my above code then parses.
You should be able to figure out the substitution for selecting nodes from here.
Note: High Lighting below mine...
<?xml version="1.0" encoding="UTF-8" ?>
- <RatingServiceSelectionResponse>
- <Response>
- <TransactionReference>
<CustomerContext>Complex Rate Request</CustomerContext>
<XpciVersion>1.0</XpciVersion>
</TransactionReference>
<ResponseStatusCode>1</ResponseStatusCode>
<ResponseStatusDescription>Success</ResponseStatusDescription>
</Response>
- <RatedShipment>
- <Service>
<Code>01</Code>
</Service>
<RatedShipmentWarning>Oversize 1 does not apply, and has automatically been removed from Package 1.</RatedShipmentWarning>
- <BillingWeight>
- <UnitOfMeasurement>
<Code>LBS</Code>
</UnitOfMeasurement>
<Weight>58.0</Weight>
</BillingWeight>
+ <TransportationCharges>
<CurrencyCode>USD</CurrencyCode>
<MonetaryValue>138.70</MonetaryValue>
</TransportationCharges>
- <ServiceOptionsCharges>
<CurrencyCode>USD</CurrencyCode>
<MonetaryValue>27.65</MonetaryValue>
</ServiceOptionsCharges>
- <TotalCharges>
<CurrencyCode>USD</CurrencyCode>
<MonetaryValue>166.35</MonetaryValue>
</TotalCharges>
<GuaranteedDaysToDelivery>1</GuaranteedDaysToDelivery>
<ScheduledDeliveryTime>12:00 Noon</ScheduledDeliveryTime>
- <RatedPackage>
- <TransportationCharges>
Caryl
mopacfan
Aug 17th 2004, 1:06 pm
McDar,
If it the response did not have the nested elements, I think it would be pretty easy to get the element by the id and then display the data. Because nested two or three levels down, I can't figure out how to get down to activity elements, get their data and then hit the next activity element.
mcdar
Aug 18th 2004, 4:12 am
To get Tracking Number:
Set NodeList = mydoc.documentElement.selectNodes("Package")
Response.Write NodeList.Item(x).selectSingleNode("TrackingNumber").Text
Caryl
mopacfan
Aug 18th 2004, 6:32 am
I don't think I'm making much sense. If you look at the xml that's returned, I need to be able to loop through the <activity details> and display the data under each.
RoLYroLLs
Sep 6th 2004, 8:28 pm
Hey mopacfan. I do understand what you want. the problem was I couldn't get the same response, so I can develop some code to parse thru the xml results. I am currently still trying to work on getting results, Thanks to jongalloway, I at least got some real XML results, only now I get:
<?xml version="1.0" ?>
- <TrackResponse>
- <Response>
- <TransactionReference>
<CustomerContext>Example 1</CustomerContext>
<XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<ResponseStatusCode>0</ResponseStatusCode>
<ResponseStatusDescription>Failure</ResponseStatusDescription>
- <Error>
<ErrorSeverity>Hard</ErrorSeverity>
<ErrorCode>151044</ErrorCode>
<ErrorDescription>No tracking information available</ErrorDescription>
</Error>
</Response>
</TrackResponse>
Will keep trying and will post here when I find or write parsing code for this. Hope you would do the same if you find or write it before me.
europebell
Mar 25th 2005, 5:08 pm
Hello mopacfan,
are you still looking for help with your XML tracking?
I Work for the Ebusiness department by ups and have writen my own codes for almost all the ÚPS Xml Tools
if you still need help drop me a line. heres a link to my demo.
http://www.bell-edv.com/portal/upstracking/tracking.asp
Best regards
Stephen J. Bell
mopacfan
Mar 25th 2005, 5:11 pm
Thank you very much for your generous offer. I did, in fact, get the xml application working. After doing much reading and taking an intermediate xml class, I was able to figure out how to parse the xml file and display the results. My code has been in use now for several months. However, I will keep your url bookmarked just in case I need to do something a little more advanced.
Thanks again,
Michael
riziko
Mar 26th 2005, 12:23 am
Hey guys we are talking ASP not PHP.
I recommend using XSL. It is a formatting language used to format XML documents for output. You can output to HTML, XML or text.
So you could write an XSL stylesheet like this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"/>
<xsl:template match="/">
<html><title>test</title>
<body>
<xsl:apply-templates select="TrackResponse/Shipment/Package/Activity"/>
</body>
</html>
</xsl:template>
<xsl:template match="Activity">
<p>Location: <xsl:value-of select="ActivityLocation/Description"/><p>
<!-- output more fields here -->
</xsl:template>
</xsl:stylesheet>
Then call the Transform method and pass the XSL and the XML documents.
Ross
bmw
May 24th 2005, 10:21 am
hello,
I would like to create asp page that gets shipping rates from UPS website.
I need to send package (size, weight, zip, country...etc) information from checkout page and receive shipping rates options and let customer select the rate. Finally, shipping cpst will be added to total.
I have looked at UPS online tools and documents. I am new to xml. I do not know where to start.
Thanks
mopacfan
May 24th 2005, 11:18 am
bmw,
I can probably help point you in the right direction. Send me your code for which you want to program against and I'll see what I can do.
Mopacfan
bmw
May 25th 2005, 7:32 am
mopacfan,
I do not have specific code. I have sample codes from ups online tools. But I do not know where to start. I need to know how I can put all codes together as asp page.
I have looked at mcdar's code. It is getting specific rate types. But I need to put these fields from form fields.
I am trying to do:
take information from form fields (package size and weight, zip, city, state...etc),
send UPS to request shipping rate,
receive results,
let user select shipping typwe/rate,
and this rate will be added to billing amount.
if you or someone used ups tools before, please guide me to put all together.
Thanks a lot.
BMW
youngoz
Jun 22nd 2005, 2:39 pm
Has anyone got the UPS Rates and Service to work under ASP.NET?? If you can you please sent me the block of codes or give me an Example. Thanks:)
fauzia
Jul 5th 2005, 5:08 am
i tried Caryl code(posted on 06-08-2004) on localhost with net facility.
i got error message "msxml3.dll: server not found on line 14.
Kindly give a little supporting comments .
I am working on ASP page.I need to track shippment of UPS.
From the specs i got ,i have to send an XML_request to the ups.com/xml/track and i will get reponse in xml-doc again.
If i am true ,kindly confirm me if the code Caryl posted on 06-08-2004 will help me or not?If no.Then i would like to get what changs i have to do in code.
If yes then resolve the cause of error message "server not found".
It is important to mention that i am testing my code from localhost.
Do i need MSXML to install? or i need to upload the trial page ??.
boyice
Jun 10th 2006, 5:49 pm
mopacfan,
I do not have specific code. I have sample codes from ups online tools. But I do not know where to start. I need to know how I can put all codes together as asp page.
I have looked at mcdar's code. It is getting specific rate types. But I need to put these fields from form fields.
I am trying to do:
take information from form fields (package size and weight, zip, city, state...etc),
send UPS to request shipping rate,
receive results,
let user select shipping typwe/rate,
and this rate will be added to billing amount.
if you or someone used ups tools before, please guide me to put all together.
Thanks a lot.
BMW
Hi,
I just start to touch UPS API with ASP/XML too.
I already test everything and it runs pretty well accroding to the code in this topic.
You can add My msn boyice@hotmail.com,
We can talk about it if you still not solute it.
For Other cool guy/gal:
I have last question for userid/password/XML accessnumber of UPS.
The userid/password is my account of UPS.com?
sanjit
Feb 2nd 2007, 11:37 pm
Am using PHP 4.0. I am trying to integrate UPS with my shopping cart for calculating shipping cost. Can anyone tell me how am i to do it. thanks
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.