Dominic, I solved the problem with the cftry/cfcatch combo that Dave
suggested in a previous email.

But in a nutshell, imagine this. You are looping through an array. You
expect that the array will have 5 elements of xml data because that has been
the case for the last 2 years. For whatever reason, now some arrays only
contain 4 elements. (Not 5 elements with one blank value.) I was/am trying
to figure out how to elegantly to display the data w/o any errors when the
missing element was cfoutput-ted.

XMLSearch, isdefined, cfparam and ArrayIsDefined were not working (at least
for me).

Thanks, Che

-----Original Message-----
From: Dominic Watson [mailto:[EMAIL PROTECTED] 
Sent: Thursday, November 15, 2007 6:45 AM
To: CF-Talk
Subject: Re: I really code use some Web Service/XML help.

If the problem is that the array you are looping contains 'undefined'
values, you could try this code to remove them:

<cfscript>
foo = ArrayNew(1);
foo[2] = "";

myArray.RemoveAll(foo);
</cfscript>

Or is it that some 'ProductInformation' elements do not contain all the
expected sub-elements?

Another thing to try is to use XMLSearch to return an array of
'ProductInformation' elements which will simplify the code and perhaps solve
the problem:

<cfset aProducts = XMLSearch(xmlContent,"//ProductInformation");
<cfloop from="1" to="#ArrayLen(aProducts)#" index="i"> <cfoutput>Product
link: #aProducts[i].productLink.xmlText#</cfoutput>
</cfloop>

Regards,

Dominic


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade to ColdFusion 8 and integrate with Adobe Flex
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:293366
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