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