You should replace:
StructIsEmpty(newsbank.collection.nbx[newsNum].HEADERFIELDS.SHL)

With:
NOT (StructKeyExists(newsbank.collection.nbx[newsNum].HEADERFIELDS,
"SHL") AND NOT
StructIsEmpty(newsbank.collection.nbx[newsNum].HEADERFIELDS.SHL))

If the above does not work, you should try this:
<cfset sttnbx = newsbank.collection.nbx[newsNum]>
<cfset sttheaderfields = sttnbx.HEADERFIELDS>
<cfif StructKeyExists(sttheaderfields, "SHL") AND
StructKeyExists(sttheaderfields.SHL, "VALUE")>
        <cfset SUBHEAD = sttheaderfields.SHL.VALUE>
<cfelse>
        <cfset SUBHEAD="">
</cfif>


In pre-MX CFML, adding dots after [] is a bad idea and can cause hard to
debug problems.

----------------------------
James Ang
Programmer
MedSeek, Inc.
[EMAIL PROTECTED]



-----Original Message-----
From: Howard Owens [mailto:[EMAIL PROTECTED]] 
Sent: Friday, December 13, 2002 3:40 PM
To: CF-Talk
Subject: Help with this Struct question, please


I have an XML document -- a collection of newsstories that I'm trying to
parse.

I'm using CF_SOXML to read the data and convert it to structures and
arrays.

There is an optional field in the XML called SHL.

Since the key of the struct doesn't always exist, I'm trying to find a
way to intelligently deal with it.

Here's what I've tried (everything has failed, so far):

<cfif StructIsEmpty(newsbank.collection.nbx[newsNum].HEADERFIELDS.SHL)>
                <cfset
SUBHEAD=newsbank.collection.nbx[newsNum].HEADERFIELDS.SHL.VALUE>
        <cfelse>
                <cfset SUBHEAD="">
</cfif>

I've also tried StructKeyExists() and IsStruct()

And each time I get an error that looks something like this:


An error occurred while evaluating the expression: 
 StructIsEmpty(newsbank.collection.nbx[newsNum].HEADERFIELDS.SHL)
Error near line 54, column 7. 
The member "SHL" in dimension 0 of object "HEADERFIELDS" cannot be
found. Please, modify the member name.

I've also tried <cfparam>ing
newsbank.collection.nbx[newsNum].HEADERFIELDS.SHL.VALUE, and CF spits
back profanity at me for that one as well.

H.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

Reply via email to