www.webdeveloper.com
Results 1 to 2 of 2

Thread: Arrays and XML

  1. #1
    Join Date
    Dec 2002
    Location
    St. Louis, MO, USA
    Posts
    1,582

    Red face Arrays and XML

    Hello, everyone.

    I'm attempting to create a pricing module for Amazon. Basically, I give Amazon ten items at a time to get all pricing information for each item. The data is being returned in XML.

    What I'd LIKE to do is take the first XML response that contains up to the first ten offers (sorted by seller name, includes prices for new, used, collectible, and refurbished), the total number of offer pages, and some other tidbits that I don't need, and put what I need into an array to hold on to while I make any necessary additional calls to Amazon for subsequent offers if there are more than ten offers for any item.

    Then take that array and push the data into a table on my database for sorting and whatnot.

    Problem is: getting the XML data from Amazon into an array. I'm using XMLParse() to at least get it into a CF struct, but creating a specific array is becoming difficult ( I don't work with arrays very often. )

    I'm getting the following error message : You have attempted to dereference a scalar variable of type class coldfusion.runtime.Array as a structure with members.

    How do I declare members of an array?

    Thanks,

    ^_^

  2. #2
    Join Date
    Feb 2006
    Posts
    520
    Your issue here is the way you're parsing the xml file.
    It's hard to tell where exacly since you did not provide xml file nor the code you're using to parse it.

    Here is a sample of the xml parse you can look at:
    Code:
    <cfscript>
       myxmldoc = XMLParse(response.filecontent);
       outXml = '';
       selectedElements2 = XmlSearch(myxmldoc, "/response/body/subresponse/serviceavailabilityresponse/availabilityresult/qualifiedservices/dslservice");
       for (i = 1; i LTE ArrayLen(selectedElements2); i = i + 1)   
       outXml = (outXml & ',' & selectedElements2[i].servicebrandname.XmlText );
    </cfscript>
    oh and yeah here's how you capture the xml response:
    Code:
    <cfhttp result="response" url="https://xapi-test.covad.com/servlet/MainVCAServlet" method="post" >
    <cfhttpparam name="request" type="xml" value="#TRIM(xmlRequest)#">
    </cfhttp>
    <cfdump var="#XMLParse(response.filecontent)#">
     <cfset myXml = #XMLParse(response.filecontent)# />
    Last edited by TiGGi; 09-09-2009 at 04:54 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles