Arrays and XML
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?
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:
oh and yeah here's how you capture the xml response:
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 );
<cfhttp result="response" url="https://xapi-test.covad.com/servlet/MainVCAServlet" method="post" >
<cfhttpparam name="request" type="xml" value="#TRIM(xmlRequest)#">
<cfset myXml = #XMLParse(response.filecontent)# />