Solved

Looping through and XML documetn with Coldfusion

Posted on 2010-09-12
9
516 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
ID: 33657789
Do you have PHP available to you?
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 33657796
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
ID: 33658565
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
ID: 33658582
Zvonko
Here is the XML file
youtube.xml
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 14

Author Comment

by:RickEpnet
ID: 33659347
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
ID: 33662706
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
ID: 33663466
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
ID: 33663777
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
ID: 33664078
I will give it a try.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

867 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

18 Experts available now in Live!

Get 1:1 Help Now