Solved

Looping through and XML documetn with Coldfusion

Posted on 2010-09-12
9
514 Views
Last Modified: 2013-11-18
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
0
Comment
Question by:RickEpnet
9 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Do you have PHP available to you?
0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
Can you provide the xml file either by upload to EE or poste the xml on the server like the test.html.
0
 
LVL 14

Author Comment

by:RickEpnet
Comment Utility
Ray_Paseur
I do have PHP on this server but I am not going to use it for this.
0
 
LVL 14

Author Comment

by:RickEpnet
Comment Utility
Zvonko
Here is the XML file
youtube.xml
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 14

Author Comment

by:RickEpnet
Comment Utility
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

0
 
LVL 4

Expert Comment

by:silvera21
Comment Utility
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
0
 
LVL 14

Author Comment

by:RickEpnet
Comment Utility
silvera21
I would like to see an example but the link only took me to a CFML Reference page.
0
 
LVL 4

Accepted Solution

by:
silvera21 earned 500 total points
Comment Utility
Sorry, here is the link (stupid frame!):

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_j-l_16.html#2393950

The collection would probably be objRSS.feed.entry

This isn't tested, so it may need some tweaking, but maybe...

<cfloop collection="#objRSS.feed.entry#" item="entry">
    <cfset isembed = "N">
    <cfloop collection="#entry.accesscontrol#" item="access">
          <cfif access.XmlAttributes.action is "embed" AND access.XmlAttributes.permission is "allowed">      
                          <cfset isembed = "Y">       
            </cfif>

    </cfloop>
</cfloop>
0
 
LVL 14

Author Comment

by:RickEpnet
Comment Utility
I will give it a try.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now