Link to home
Start Free TrialLog 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)

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

feed.entry.accessControl.XmlAttributes.permission
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

ASKER

Ray_Paseur
I do have PHP on this server but I am not going to use it for this.
Zvonko
Here is the XML file
youtube.xml
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

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 
silvera21
I would like to see an example but the link only took me to a CFML Reference page.
ASKER CERTIFIED SOLUTION
Avatar of silvera21
silvera21
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I will give it a try.