Solved

Looping through and XML documetn with Coldfusion

Posted on 2010-09-12
9
520 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 110

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Author Comment

by:RickEpnet
ID: 33658582
Zvonko
Here is the XML file
youtube.xml
0
 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Application.cfc - what is the order of events? 4 91
XML Removal- Powershell 4 40
Combining Queries 7 53
Customizing XML with Powershell 2 41
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

739 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