Link to home
Create AccountLog in
Avatar of RickEpnet
RickEpnetFlag for United States of America

asked on

Looping through and XML documetn with Coldfusion

I need to loop through and XML document with coldfusion. The link below opens a YouTube XML document. I want to loop through the accessControl under entry. I thought I could just use ArrayToList and this might work I just do not know how to format it or if this will not work please let me know what would.

ArrayToList(what do I put in here)

Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Do you have PHP available to you?
Avatar of Zvonko
Can you provide the xml file either by upload to EE or poste the xml on the server like the test.html.
Avatar of RickEpnet


I do have PHP on this server but I am not going to use it for this.
Here is the XML file
Never mind I got is solved myself. If any one is interested this is how it is done.

<cfhttp url='' method='get'>

<cfhttpparam type="Header" name="Accept-Encoding" value="deflate;q=0"></cfhttp>     
<cfset objRSS = xmlParse(cfhttp.filecontent)>

<cfloop index="i" from="1" to="#ArrayLen(objRSS.feed.entry)#">
       	<cfset isembed = "N">
	<cfloop index="j" from="1" to="#ArrayLen(objRSS.feed.entry[i].accessControl)#">
            <cfif objRSS.feed.entry[i].accessControl[j].XmlAttributes.action is "embed">
        	<cfif  objRSS.feed.entry[i].accessControl[j].XmlAttributes.permission is "allowed">
               	     <cfset isembed = "Y">

Open in new window

Any XML file that is parsed in coldfusion can be referenced as a struct. So a collection loop will also work, and would probably be a bit more simple (don't have to check the length). 
I would like to see an example but the link only took me to a CFML Reference page.
Avatar of silvera21
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
I will give it a try.