This a rather long email... 

i am trying to query the USPS international rate calculator via their 
API. Their response is an XML document which i am parsing via SOXML. 
This is a great tool!

an example of the xml that i receive from USPS is as 
follows..==================================================
<?xml version="1.0"?>
<IntlRateResponse>
        <Package ID="0">
                <Prohibitions>Currency of the Albanian State Bank (Banknotes in lek). 
Extravagant clothes and other articles contrary to Albanians' taste. 
Items sent by political emigres. </Prohibitions>
                <Restrictions>Hunting arms require an import permit. Medicines for 
personal use are admitted provided the addressee has a medical 
certificate.</Restrictions>
                <Observations>1. Letter packages may not contain dutiable articles. 2. 
Parcel post service extends only to: Berat Konispol Milot Bilisht Korce 
Peqin</Observations>
                <CustomsForms>Postal Union Mail (LC/AO): PS Form 2976 or 2976-A (see 
123.61) Parcel Post: PS Form 2976-A inside 2976-E 
(envelope)</CustomsForms>
                <ExpressMail>Country Code AL Reciprocal Service Name EMS Required 
Customs Form/Endorsement 1. For correspondence and business papers: PS 
Form 2976, Customs - CN 22 (Old C 1) and Sender's Declaration (green 
label). Endorse item clearly next to mailing label as BUSINESS 
PAPERS.</ExpressMail>
                <AreasServed>Tirana.</AreasServed>
                <Service ID="0">
                        <Pounds>2</Pounds>
                        <Ounces>0</Ounces>
                        <MailType>Package</MailType>
                        <Country>ALBANIA</Country>
                        <Postage>87</Postage>
                        <SvcCommitments>See Service Guide</SvcCommitments>
                        <SvcDescription>Global Express Guaranteed (GXG) Document 
Service</SvcDescription>
                        <MaxDimensions>Max. length 46", depth 35", height 46" and max. 
girth 
108"</MaxDimensions>
                        <MaxWeight>22</MaxWeight>
                </Service>
                <Service ID="1">
                        <Pounds>2</Pounds>
                        <Ounces>0</Ounces>
                        <MailType>Package</MailType>
                        <Country>ALBANIA</Country>
                        <Postage>96</Postage>
                        <SvcCommitments>See Service Guide</SvcCommitments>
                        <SvcDescription>Global Express Guaranteed (GXG) Non-Document 
Service</SvcDescription>
                        <MaxDimensions>Max. length 46", depth 35", height 46" and max. 
girth 
108"</MaxDimensions>
                        <MaxWeight>22</MaxWeight>
                </Service>
        </Package>
</IntlRateResponse>==================================================

I am very new using XML, but the way soxml parses it is by using 
cfscript and looping thorugh the array for each main object in the xml 
doc.

Following the xml2cf section, i basically loop through the array of 
objects in the xml doc as follows:
==================================================
<cfif isArray(outhere.IntlRateResponse.Package)>
  <cfloop index="package_pointer" from="1" 
to="#ArrayLen(outhere.IntlRateResponse.Package)#">
   <cfscript>
                sProhivitions = 
outhere.IntlRateResponse.Package[package_pointer].Prohibitions.value;
                sRestrictions = 
utoutherehere.IntlRateResponse.Package[package_pointer].Restrictions.valu
e;
                sObservations = 
outhere.IntlRateResponse.Package[package_pointer].Observations.value;
                sCustomsForms = 
uthouthereere.IntlRateResponse.Package[package_pointer].CustomsForms.valu
e;
                sExpressMail = 
outhere.IntlRateResponse.Package[package_pointer].ExpressMail.value;
                sAreasServed = 
outhere.IntlRateResponse.Package[package_pointer].AreasServed.value;
    </cfscript>
<cfelse>
<cfscript>
        sProhivitions = 
outhere.IntlRateResponse.Package[package_pointer].Prohibitions.value;
                sRestrictions = 
utoutherehere.IntlRateResponse.Package[package_pointer].Restrictions.valu
e;
                sObservations = 
outhere.IntlRateResponse.Package[package_pointer].Observations.value;
                sCustomsForms = 
uthouthereere.IntlRateResponse.Package[package_pointer].CustomsForms.valu
e;
                sExpressMail = 
outhere.IntlRateResponse.Package[package_pointer].ExpressMail.value;
                sAreasServed = 
outhere.IntlRateResponse.Package[package_pointer].AreasServed.value;
    </cfscript>
</cfif>==================================================


This, so far, works fine. However, the problem i enconter is when i try 
to utilize the second object: "Service". Whe i run the following code, 


<cfif isArray(outhere.IntlRateResponse.Service)>
        <cfloop index="service_pointer" from="1" 
to="#ArrayLen(outhere.IntlRateResponse.Service)#">
         <cfscript>
      //Lets grab the nodes of the information we want to display
                sPounds = 
outhere.IntlRateResponse.Service[service_pointer].Prohibitions.value;
                sOunces = 
utoutherehere.IntlRateResponse.Service[service_pointer].Restrictions.valu
e;
                sMailType = 
outhere.IntlRateResponse.Service[service_pointer].Observations.value;
                sCountry = 
uthouthereere.IntlRateResponse.Service[service_pointer].CustomsForms.valu
e;
                sPostage = 
outhere.IntlRateResponse.Service[service_pointer].ExpressMail.value;
                sSvcCommitments = 
outhere.IntlRateResponse.Service[service_pointer].AreasServed.value;
                sSvcDescription = 
outhere.IntlRateResponse.Service[service_pointer].AreasServed.value;
                sMaxDimensions = 
outhere.IntlRateResponse.Service[service_pointer].AreasServed.value;
                sMaxWeight = 
outhere.IntlRateResponse.Service[service_pointer].AreasServed.value;
    </cfscript>
</cfif>

CF throws an error saying that it cannot resolve the parameter 
outhere.IntlRateResponse.Service. Even though this does exist and indeed 
is to be an array since there are two of them.

Any help would be much appreciated!

Thank you


--------------------------------------------
Andres Leon
[EMAIL PROTECTED]
Vitacost.com
2049 High Ridge Road
Boynton Beach, Fl 33426
______________________________________________________________________
Why Share?
  Dedicated Win 2000 Server � PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to