Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting values out of XML response

Status
Not open for further replies.

kizmar2

Programmer
May 25, 2004
164
US
I am sending a request to UPS, then getting a response back based on info sent. I'm new to XML and have no clue how to get just the values back out of the response from UPS.

The following is an example of what UPS is sending back:
Code:
<?xml version="1.0"?>
	<RatingServiceSelectionResponse>
		<Response>
			<TransactionReference>
				<CustomerContext>Bare Bones Rate Request</CustomerContext>
				<XpciVersion>1.0001</XpciVersion>
			</TransactionReference>
			<ResponseStatusCode>1</ResponseStatusCode>
			<ResponseStatusDescription>Success</ResponseStatusDescription>
		</Response>
		<RatedShipment>
			<Service>
				<Code>01</Code>
			</Service>
			<BillingWeight>
				<UnitOfMeasurement>
					<Code>LBS</Code>
				</UnitOfMeasurement>
				<Weight>42.0</Weight>
			</BillingWeight>
			<TransportationCharges>
				<CurrencyCode>USD</CurrencyCode>
				<MonetaryValue>135.45</MonetaryValue>
			</TransportationCharges>
			<ServiceOptionsCharges>
				<CurrencyCode>USD</CurrencyCode>
				<MonetaryValue>0.00</MonetaryValue>
			</ServiceOptionsCharges>
			<TotalCharges>
				<CurrencyCode>USD</CurrencyCode>
				<MonetaryValue>135.45</MonetaryValue>
			</TotalCharges>
			<GuaranteedDaysToDelivery>1</GuaranteedDaysToDelivery>
			<ScheduledDeliveryTime>10:30 A.M.</ScheduledDeliveryTime>
			<RatedPackage>
				<TransportationCharges>
					<CurrencyCode>USD</CurrencyCode>
					<MonetaryValue>135.45</MonetaryValue>
				</TransportationCharges>
				<ServiceOptionsCharges>
					<CurrencyCode>USD</CurrencyCode>
					<MonetaryValue>0.00</MonetaryValue>
				</ServiceOptionsCharges>
				<TotalCharges>
					<CurrencyCode>USD</CurrencyCode>
					[red]<MonetaryValue>135.45</MonetaryValue>[/red]
				</TotalCharges>
				<Weight>23.0</Weight>
				<BillingWeight>
					<UnitOfMeasurement>
						<Code>LBS</Code>
					</UnitOfMeasurement>
					<Weight>42.0</Weight>
				</BillingWeight>
			</RatedPackage>
		</RatedShipment>
	</RatingServiceSelectionResponse>

All I really need is to be able to pull the value in red. Can anyone give me an example of how to do this?

KizMar
------------
 
Using figuratively notations from your previous thread, it is something like this.
[tt]
xmlDoc2.loadXML xmlhttp.responseText
set onode=xmlDoc2.selectSingleNode("/RatingServiceSelectionResponse/RatedShipment/RatedPackage/TotalCharges/MonetaryValue")
response.write onode.text 'the desired data so retrieved
[/tt]
 
I also found the following with does basically the same thing:

Code:
Set MonetaryValueNode = xmlResponse.documentElement.childNodes.item(1).childNodes.item(7).childNodes.item(2).childNodes.item(1)

ShipCost = MonetaryValueNode.text

Response.Write("<br>Cost of shipping: " & ShipCost & "<br>")

The only difference being the readability of the code.

Thank you!

KizMar
------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top