Okay... I've worked this every way I can think
of and, I admit it, I just don't get it.

Where am I going wrong?

Ultimately, I want to get the categories of products
and list the products of each category.

I can get the categories, along with the descriptions,
and images, but just can't figure out how to loop
through the products.

Clues for the cluesless?

Rick

PS - you can see the cfdumps in the code to show
the actual XML I'm trying to work with.  I've seen
examples of the XML data put into a database and then
worked with from there. Would that be preferable?



<cfscript>

     URLToPull = 'http://lennox.com/api/v1/z7RRSHM/categories/';

</cfscript>


<cfhttp      url     =     '#URLToPull#'
             method  =     'get'
             timeout =     '15'>        
</cfhttp>


<cfscript>

     XMLContent = trim(cfhttp.fileContent);
     XMLContent = XMLParse(XMLContent);

</cfscript>


<cfdump var = "#XMLContent#">

<cfoutput>

<cfloop from = '1' to = '#arrayLen(XMLContent.Categories.Category)#'
index='idx'>

          #XMLContent.Categories.Category[idx].CategoryName.xmlText#<br>
          #XMLContent.Categories.Category[idx].shortDescription.xmlText#<br>
          <img
src='#xmlContent.categories.Category[idx].highlightImage.xmlText#'><br>
          <br>

          <cfscript>

               URLProducts =
'http://lennox.com/api/v1/z7RRSHM/category/#idx#';

          </cfscript>

          <cfhttp     url     =     '#URLProducts#'
                      method  =     'get'
                      timeout   =     '15'>     
          </cfhttp>

          <cfscript>

               xmlProductContent = trim(cfhttp.fileContent);
               xmlProductContent = xmlParse(xmlProductContent);

          </cfscript>

          <cfdump var = "#xmlProductContent#">

          <cfloop     from     =     '1'
                      to       =
'#arrayLen(xmlProductContent.products)#'
                      index    =     'productCount'>

 
#xmlProductContent.products.subcategories[productCount].products.xmlChildren
.xmlText#<br>

          </cfloop>

</cfloop>

</cfoutput>


The last cfloop above is what I'm having trouble with...

Thanks for any help!

Rick



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349269
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to