Hey Shawn,

It's just 9am here so my apologies for a short answer (or rather, the 
short hint) - try looking into XPath. Either do a search on Google or 
take a look at the XPath spec http://www.w3.org/TR/xpath

A demo of the XML you're using would've been useful, but from what 
you've said I'm assuming it's something like this:

<rootelement>
        <blah>
        </blah>
        <event>
                <someelement/>
        </event>
        <event>
                <headerlinks>
                        <name>fred</name>
                        <url>http://www.somewhere.com</url>
                </headerlinks>
        </event>
</rootelement>  

 From what I can see, get the XML into a variable then construct your 
XPath var, perhaps something like

<cfset xpathvar = "/descendant::event/child:headerlinks"/>

Then this:

<cfset headerlinks = XMLSearch(varWithXMLInIt, xpathvar)/>

That should throw all of the elements that match your XPath expression 
into headerlinks, which will be an array.

Best to read through some articles on XPath 'cos I'm sure that the above 
expression won't do exactly what you're after. The W3C spec is, as 
usual, hefty and complicated (especially at 9am!) hence the reason why I 
think my expression won't work properly but it should give you a pointer 
on where to start looking.

Hope that helps somewhat,

  Oliver Tupman
  Key Systems Geotechnical.

Shawn Contreras wrote:

> Hello,
> 
> I am having a problem that I desperately need help with.  I am working with
> consuming XML WebServices using CFMX, here is my problem.
> 
> I have an XML child called EVENT that also has many children. However, each
> EVENT record occurence does not ALWAYS have the same children. Sometimes it
> has children called HEADERLINKS and sometimes it is does not. Of course, if
> it does have the child called HEADERLINKS, then it too has several children.
> I want to loop through and IF the HEADERLINKS child exists THEN output every
> occurence of the HEADERLINKS and its children.
> 
> I get the most recent record (which is what I want) but it stops because it
> knows that the second record doesn't contain the HEADERLINKS child.  I need
> it to continue on and look at all the other records and OUTPUT those other
> records that do have the HEADERLINKS child and it's respective children.
> 
> My code is below:
> 
> <CFSETxmlobj = xmlParse(cfhttp.fileContent, false)>
> <body>
> <CFSET EVENTS = xmlobj.irxml>
> <CFSET EVENTRoot = xmlobj.irxml.EVENTS>
> <CFSET EVENTList = EVENTRoot.EVENT>
> <CFSET EVENTListW = EVENTList.EventTitle>
> <CFSET EVENTAll = ArrayLen(EVENTRoot.xmlChildren)>
> <CFOUTPUT>
> <div align="center">
>     <font size="2" face="Verdana, Arial, Helvetica, sans-serif">Number of
> EVENTS:</font>
>  <font color="##FF0000"><strong>#EVENTAll#</strong></font></div>
> </CFOUTPUT>
> 
> <CFLOOP from="#ArrayLen(EVENTRoot.xmlChildren)#" to="1" index="i" step="-1">
> <br>
> 
> <CFIF isDefined ("EVENTList.HeaderLinks.HeaderLink")>
> 
> <CFOUTPUT>
> <table width="100%" border="0" cellspacing="0" cellpadding="0">
>       <tr>
>         <td><div align="center"><a
> href="#EVENTList[i].HeaderLinks.HeaderLink.Webcasts.Webcast.Streams.Stream.U
> RL.xmlText#">
>               <img
> src="#EVENTList[i].HeaderLinks.HeaderLink.ImageURL.xmlText#"
> border="0"></a></div></td>
>         <td><div align="center"><font size="2" face="Verdana, Arial,
> Helvetica,
> sans-serif">#EVENTList[i].HeaderLinks.HeaderLink.Title.xmlText#<br>
>             </font></div></td>
>       </tr>
>       <tr bgcolor="##000099">
>         <td></td>
>         <td height="1"></td>
>       </tr>
>       <tr>
>         <td>&nbsp;</td>
>         <td>&nbsp;</td>
>       </tr>
>     </table>
> </CFOUTPUT>
> </CFIF>
> </CFLOOP>
> 
> Thank you in advance for your help!
> 
> Shawn Contreras
> 
> 
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq

Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. 
http://www.fusionauthority.com/signup.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to