Skip to main content
WolfShade
Legend
August 3, 2009
Question

Arrays and XML

  • August 3, 2009
  • 1 reply
  • 953 views

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,

^_^

    This topic has been closed for replies.

    1 reply

    Inspiring
    August 3, 2009

    If you are having trouble with arrays, the cfml reference manual has good examples.   Second, are you sure that xmlParse() returns a structure?  Next, does the error message cold fusion provides give you any hints?

    Finally, cfdump is your best troubleshooting freind.

    WolfShade
    WolfShadeAuthor
    Legend
    August 4, 2009

    I was under the impression that XMLParse() converts XML to a CF Struct.  Guess not.

    Using CFCATCH.Message and CFCATCH.Detail, the only error message I get is what I posted, nothing else; no other hints.

    So, since XMLParse takes XML data and makes an XML Document string from it (which I think is totally ridiculous), is there anything available (preferably native as opposed to third-party) that will convert an XML string into a CF Struct?

    Thanks,

    ^_^

    Inspiring
    August 4, 2009

    WolfShade,

    Like Dan suggested, you won't find a better tool than <cfdump>!.

    Dumping your xml variable using the <cfdump> tag, will give you structure kinda view that you are looking for. Give it a try!.