?
Solved

Looping through and XML documetn with Coldfusion

Posted on 2010-09-12
9
Medium Priority
?
523 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 111

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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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 2000 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

Industry Leaders: 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!

Question has a verified solution.

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

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, …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

770 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