RickEpnet
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.X mlAttribut es.permiss ion
ArrayToList(what do I put in here)
http://www.pigskinu.com/test.html
feed.entry.accessControl.X
Do you have PHP available to you?
Can you provide the xml file either by upload to EE or poste the xml on the server like the test.html.
ASKER
Ray_Paseur
I do have PHP on this server but I am not going to use it for this.
I do have PHP on this server but I am not going to use it for this.
ASKER
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>
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
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Part_3_CFML_Ref_1.html
ASKER
silvera21
I would like to see an example but the link only took me to a CFML Reference page.
I would like to see an example but the link only took me to a CFML Reference page.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I will give it a try.