NogDog wrote:If using PHP5 (which I hope you are by now), you should look into the [man]SimpleXML[/man] functions for help with this.
Yeah , I used xmlrpc_decode() function , but it gives me fatal error , call to undefined function.....even tried recurseXML , xml_to_array() also...
actually , i have a script of XML as below...
I have a function called get_rate, the code for the get_rate is below. I call that function in which i have added the UPS XML script.And the answer I am getting is as below.
[code]
XML Resposne:
THE Code for Get_rate() function is ,
function getRate(
$w2,
$s2,
$r1,
$p2,
$c2,
$service_code
) {
$this->_xml_request =<<<XML
<?xml version="1.0"?>
<AccessRequest xml:lang="en-US">
<AccessLicenseNumber>$this->_access_key</AccessLicenseNumber>
<UserId></UserId>
<Password></Password>
</AccessRequest>
<?xml version="1.0"?>
<RatingServiceSelectionRequest xml:lang="en-US">
<Request>
<TransactionReference>
<CustomerContext>Shipping</CustomerContext>
<XpciVersion>1.0001</XpciVersion>
</TransactionReference>
<RequestAction>$this->_request_option</RequestAction>
<RequestOption>$this->_request_option</RequestOption>
</Request>
<PickupType>
<Code>01</Code>
</PickupType>
<Shipment>
<Shipper>
<ShipperNumber></ShipperNumber>
<Address>
<City></City>
<StateProvinceCode></StateProvinceCode>
<PostalCode></PostalCode>
<CountryCode></CountryCode>
</Address>
</Shipper>
<ShipTo>
<Address>
<StateProvinceCode>$s2</StateProvinceCode>
<PostalCode>$p2</PostalCode>
<CountryCode>US</CountryCode>
<ResidentialAddress>$r1</ResidentialAddress>
</Address>
</ShipTo>
<ShipFrom>
<Address>
<StateProvinceCode></StateProvinceCode >
<PostalCode></PostalCode>
<CountryCode></CountryCode>
</Address>
</ShipFrom>
<Service>
<Code>03</Code>
</Service>
<Package>
<PackagingType>
<Code>02</Code>
</PackagingType>
<PackageWeight>
<UnitOfMeasurement>
<Code>LBS</Code>
</UnitOfMeasurement>
<Weight>{$w2}</Weight>
</PackageWeight>
</Package>
<RateInformation>
<NegotiatedRatesIndicator/>
</RateInformation>
</Shipment>
</RatingServiceSelectionRequest>
XML;
AND BELOW is the answer what I got ............
<?xml version="1.0"?><RatingServiceSelectionResponse><Response><TransactionReference><CustomerContext>Shipping</CustomerContext><XpciVersion>1.0001</XpciVersion></TransactionReference><ResponseStatusCode>1</ResponseStatusCode><ResponseStatusDescription>Success</ResponseStatusDescription></Response><RatedShipment><Service><Code>03</Code></Service><RatedShipmentWarning>Your invoice may vary from the displayed reference rates</RatedShipmentWarning><BillingWeight><UnitOfMeasurement><Code>LBS</Code></UnitOfMeasurement><Weight>36.0</Weight></BillingWeight><TransportationCharges><CurrencyCode>USD</CurrencyCode><MonetaryValue>31.14</MonetaryValue></TransportationCharges><ServiceOptionsCharges><CurrencyCode>USD</CurrencyCode><MonetaryValue>0.00</MonetaryValue></ServiceOptionsCharges><TotalCharges><CurrencyCode>USD</CurrencyCode><MonetaryValue>31.14</MonetaryValue></TotalCharges><GuaranteedDaysToDelivery></GuaranteedDaysToDelivery><ScheduledDeliveryTime></ScheduledDeliveryTime><RatedPackage><TransportationCharges><CurrencyCode>USD</CurrencyCode><MonetaryValue>31.14</MonetaryValue></TransportationCharges><ServiceOptionsCharges><CurrencyCode>USD</CurrencyCode><MonetaryValue>0.00</MonetaryValue></ServiceOptionsCharges><TotalCharges><CurrencyCode>USD</CurrencyCode><MonetaryValue>31.14</MonetaryValue></TotalCharges><Weight>36.0</Weight><BillingWeight><UnitOfMeasurement><Code>LBS</Code></UnitOfMeasurement><Weight>36.0</Weight></BillingWeight></RatedPackage></RatedShipment></RatingServiceSelectionResponse>
...
i wanted to have the MonetaryValue filed to be stored into one variable.....(i.e 31.14 to be stored in a variable).
<TotalCharges><CurrencyCode>USD</CurrencyCode><MonetaryValue>31.14</MonetaryValue></TotalCharges>