Avatar of RickEpnet
RickEpnet
Flag 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)

http://www.pigskinu.com/test.html

feed.entry.accessControl.XmlAttributes.permission
Web Languages and StandardsXMLColdFusion Language

Avatar of undefined
Last Comment
RickEpnet

8/22/2022 - Mon
Ray Paseur

Do you have PHP available to you?
Zvonko

Can you provide the xml file either by upload to EE or poste the xml on the server like the test.html.
RickEpnet

ASKER
Ray_Paseur
I do have PHP on this server but I am not going to use it for this.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
RickEpnet

ASKER
Zvonko
Here is the XML file
youtube.xml
RickEpnet

ASKER
Never mind I got is solved myself. If any one is interested this is how it is done.


<cfhttp url='http://gdata.youtube.com/feeds/api/users/#trim(getvdfrompl.ytchannel)#/uploads?q=FootBall&start-index=1&max-results=25&v=2' 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">
                 </cfif>        	
            </cfif>
        </cfloop>
</cfloop>

Open in new window

silvera21

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).

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Part_3_CFML_Ref_1.html 
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
RickEpnet

ASKER
silvera21
I would like to see an example but the link only took me to a CFML Reference page.
ASKER CERTIFIED SOLUTION
silvera21

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
RickEpnet

ASKER
I will give it a try.