> howdy all, so I've got a little bug I'm having a tough time 
> with. I'm new to manipulating XML in CF. It's pretty easy 
> however, but I've run into a problem I'm not sure how to solve.
> 
> The Google box returns an XML structure that I've processed. 
> But from time to time, I find that the 'T' element (Title) is 
> not returned. And it errors out.
> 
> I tried:
> <cfloop from="1" to="#ArrayLen(XMLContent.GSP.RES.R)#" 
> index="idx"> <cfif isDefined("XMLContent.GSP.RES.R[idx].T")>
> 
> But I get error:
> Element T is undefined in a Java object of type class 
> coldfusion.xml.XmlNodeMap referenced as 
> 
> If I do:
> <cfif isDefined("XMLContent.GSP.RES.R")>
> 
> It works fine.... but that's not what I need.
> 
> Thoughts? Should I place the current index node into a var 
> and then test?

First, I'm very surprised that you're seeing R elements that don't have a
child T. Can you confirm that these are actually what you're getting back
from your GSA or Mini?

Second, you can't test for the existence of array elements with IsDefined.
But you can store the array element within a variable, then test for the
existence of members of that variable:

<cfloop ...>
        <cfset thisR = XMLContent.GSP.RES.R[idx]>
        <cfif IsDefined("thisR.T")>
</cfloop>

Don't forget, you can also use XPath expressions from within CF. You might
find that an easy alternative to accessing elements directly, although to be
honest I haven't tried that myself from within CF while using Google search
result XML.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Training: Adobe/Google/Paperthin Certified Partners
http://training.figleaf.com/

WebManiacs 2008: the ultimate conference for CF/Flex/AIR developers!
http://www.webmaniacsconference.com/

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;192386516;25150098;k

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:304608
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to